Advertisements

Archive

Posts Tagged ‘query’

SQL: Condition in Count()

July 7, 2015 1 comment

Condition in count()

SELECT
count(case when EventTypeID =1 then 1 else null end) as TotalTournamentsAttended,
count(case when EventTypeID =2 then 1 else null end) as TotalLeaguesAttended

FROM

[Tables]

 

 

Advertisements

MySQL : coalesce in mysql


DESCRIPTION

The MySQL COALESCE function returns the first non-null expression in the list.

SYNTAX

The syntax for the MySQL COALESCE function is:

COALESCE( expression1, expression2, ... expression_n )

e.g.

SELECT COALESCE(t.col,1) FROM Table t

Above query will return 1 if t.col is null.

Hope this help !

Categories: Sql Server Tags: , , ,