标签:stat import case when mic else lse sel when ESS
可以一同使用 DISTINCT 和 COUNT 关键词,来计算非重复结果的数目。
SELECT COUNT(DISTINCT column(s)) FROM table
注意:下面的例子仅适用于 ORACLE 和 Microsoft SQL server,不能用于 Microsoft Access。
Company | OrderNumber |
---|---|
IBM | 3532 |
W3School | 2356 |
Apple | 4698 |
W3School | 6953 |
SELECT COUNT(Company) FROM Orders
结果:
4
SELECT COUNT(DISTINCT Company) FROM Orders
结果:
3
count(distinct case when photo=‘1‘ or photo=‘2‘ then id else null end )PHnumber
count( DISTINCT CASE WHEN UCS.status=2 AND ( M.is_relearn=0 or M.is_relearn=1) THEN UCS.status ELSE NULL END )
标签:stat import case when mic else lse sel when ESS
原文地址:https://www.cnblogs.com/deepalley/p/10703393.html