我正在嘗試創建SQL Select,它根據字段返回特定字段的計數。 所以,這是我想要做的。SQL Select for multiple where子句
Select count(distinct id) as TotalCount, -- this will be the total of id
count(distinct id where type='A') as TotalA, -- this will be total when type='A'
count(distinct id where type='B') as TotalB -- This will be total when type = 'B'
from MyTable
基本上TotalCount = TotalA + TotalB。
如何在SQL Select語句中實現此目的? 謝謝。
SUM(1)!= COUNT(DISTINCT) – 2010-12-21 23:55:15
吧,我剛剛看了評論說: 「總」 – 2010-12-22 00:12:45