当前页面: 开发资料首页 → J2SE 专题 → 求一条sql语句???急。。。。
求一条sql语句???急。。。。
摘要: 求一条sql语句???急。。。。
房间 类型 状态
1 2人 正常
2 2人 正常
3 4人 正常
4 2人 停用
现在已经知道: 类型(2人,3人,4人) 状态(正常,停用)
如何用一条语句 选出 状态为“正常” or “停用” 下“类型” 的个数的统计:
即 正常 :2人 2 ;3人 0;4人 1;
select count(*),状态 from table group by 状态
是不是这样的
这样子不行, 3 人的房间没有 ,结果只有
2
1
3人的统计不出来啊
顶
类型(2人,3人,4人) 是固定的三项?
select count(*),状态 from table where 状态='正常' group by 类型
select count(*),状态 from table where 状态='正常' group by 类型
union select count(*),状态 from table where 状态='停用group by 类型
select count(*),状态 from table where 状态='正常' group by 类型
union select count(*),状态 from table where 状态='停用 group by 类型