sql-server-2008microsoft-expression-web

Query statement in Expression Web


Sir, the following statement in Expression Web is work for count one criteria SELECT COUNT(Rly) AS CR FROM SPAD WHERE Rly='CR'.

Now the issue is that if more than one criteria is required in same column, for example Count(Rly) AS ER FROM SPAD WHERE Rly='ER'

What statement will be required? Please help.


Solution

  • To count both values:

    SELECT COUNT(Rly) AS TheCount FROM SPAD WHERE Rly IN ('CR', 'ER')
    

    To count separately in one go:

    SELECT COUNT(Rly) AS TheCount, Rly 
    FROM SPAD
    WHERE Rly IN ('CR', 'ER')
    GROUP BY Rly