仅当价格不是0,00时才依靠SQL

use*_*511 2 sql group-by

我有这样的表:

ID  Price  ZONE
--  -----  ----
1   0,00    A
2   6,00    A
3   8,56    A
4   0,00    B
Run Code Online (Sandbox Code Playgroud)

我想表明:

ZONE TOTAL
---- -----
A    2
B    0
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

提前谢谢你.

And*_*mar 6

假设Price是一个文本字段:

select  zone
,       count(case when Price <> '0,00' then 1 end) as total
from    YourTable
group by
        zone
Run Code Online (Sandbox Code Playgroud)

如果price是数字字段,请替换Price <> '0,00'为Price > 0.