sql
todotask
这个作者很懒,什么都没留下…
展开
-
sql 行转列实现
SELECT class_id, sum( CASE WHEN sex = '男' THEN 1 ELSE 0 END ) AS '男', sum( CASE WHEN sex = '女' THEN 1 ELSE 0 END ) AS '女'FROM studentGROUP BY class_id; ...原创 2018-07-29 14:55:45 · 163 阅读 · 0 评论 -
分段统计函数(年龄分段)
SELECT CASEWHEN YEAR (CURDATE()) - YEAR (birthday) - ( RIGHT (CURDATE(), 5) < RIGHT (birthday, 5)) <= 10 THEN '[0-10)岁'WHEN YEAR (CURDATE()) - YEAR (birthday) - ( RIGHT (CURDATE(), 5) &l...原创 2018-07-29 15:46:16 · 5297 阅读 · 1 评论