开发者

How do I do a where clause in sql and return a count back?

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 o开发者_运维知识库f 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.


You are there..just use:

Select Count(*)
From Product
where active = 'true'

Assuming your active field is of varchar or something similar.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜