您的位置:首页 > 数据库

SQL 多条件查询多结果

2016-03-15 09:40 399 查看
var query = 'SELECT COUNT(*) as count_all , ' +
'SUM(Case when checkResult = 1 then 1 else 0 end ) as count_no, ' +
'SUM(Case when checkResult = 2 then 1 else 0 end ) as count_even, ' +
'SUM(Case when checkResult = 3 then 1 else 0 end ) as count_earn, ' +
'SUM(Case when checkResult = 4 then 1 else 0 end ) as count_lose, ' +
'checkTypeView as checkTypeView, '+
'checkNumber as checkNumber, '+
'FROM CheckList' +
' group by cellType';
这样查询结果将返回一个object对象,包含总数count_all,checkResult各不同的总数count_no,count_even,count_earn,count_lose,已经'checkTypeView 、'checkNumber 对象


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: