case when then else
来源:互联网 发布:.net 4.6 windows 8 编辑:程序博客网 时间:2024/04/20 14:19
// http://blog.csdn.net/lenotang/archive/2008/08/21/2806658.aspx
SELECT
CASE
WHEN price IS NULL THEN 'Unpriced'
WHEN price < 10 THEN 'Bargain'
WHEN price BETWEEN 10 and 20 THEN 'Average'
ELSE 'Gift to impress relatives'
END AS Range,
Count(*)
FROM titles
GROUP BY
CASE
WHEN price IS NULL THEN 'Unpriced'
WHEN price < 10 THEN 'Bargain'
WHEN price BETWEEN 10 and 20 THEN 'Average'
ELSE 'Gift to impress relatives'
END
GO
select 中用了case
group by 中重复一次
结果:
Average 9
Bargain 4
Gift to impress relatives 3
Unpriced 2
- case when then else
- case when then else
- case when then else
- case when then else
- case when then else end
- case when then else end
- case when then else end
- case+when+then+else+end
- case when then else end
- sql case when then else
- case when then else end
- case when then else end
- case .. when .. then .. else .. end
- case when then else end
- Oracle case when then else
- case when then else end
- Case when then else end
- case when then else end
- 挑水别忘了挖井 上班也可以创业
- 帮个忙,谢谢好心人
- OSI七层网络协议之传输层
- ACM初赛试题(1)
- XMLhttpRequest 封装
- case when then else
- JAVA中使用printf(System.out.printf)如何格式化输出数字
- 人证
- ACM初赛试题(2)
- IO
- 既然选择远方,那就只顾风雨兼程
- ACM初赛试题(3)
- 找工记录(10.19)
- 成员函数指针和成员变量指针