How do I do a where clause in sql and return a count back?
        Posted  
        
            by chobo2
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by chobo2
        
        
        
        Published on 2010-03-23T02:05:07Z
        Indexed on 
            2010/03/23
            2:11 UTC
        
        
        Read the original article
        Hit count: 355
        
sql
Hi
I am using mssql and I want to make a query that returns a count back with a where clause.
Like say I have a product Table
ProductId
ProductName
Active
So how would I make it
I have like
Select Count(*)
From Product
now I don't know how to filter it so it only could if Active = true;
So if there are 3 active products then it would return a count of 3 even if there is a hundred rows in the db and the other 97 are only not active.
so the where clause would be probably like
where active = true
I am not sure how to put them together though.
© Stack Overflow or respective owner