sql 视图 字段条件统计

select top(10) FModelCode,FProductTypeName,FBrandName,FOrganizationName,KOrganizationID,count(0) FALLCount,
sum(case when FStatus >1 then 1 else 0 end) SaleCount,
sum(case when FStatus >0 then 1 else 0 end) SendCount
from VProduct
group by FModelCode,FProductTypeName,FBrandName,FOrganizationName,KOrganizationID
order BY SaleCount DESC

sum(如果符合条件1否则0) 这样就可以按照条件统计个数了

上一篇:QXcbConnection: XCB error: 145 (Unknown), sequence: 171, resource id: 0 报错问题


下一篇:android studio如何查看数据库文件