mysql中AS别名数字

AS别名不能直接是数字,相当于以字符形式展示,

示例sql

select
  (case name when name then name ELSE '合计' END ) AS 用户,
  count(case HOUR(recordTime) when '0'  then  '0'  END ) AS '00' ,
  count(case HOUR(recordTime) when '1'  then  '1'  END ) AS '01' ,
  count(case HOUR(recordTime) when '2'  then  '2'  END ) AS '02' ,
  count(case HOUR(recordTime) when '3'  then  '3'  END ) AS '03' ,
  count(case HOUR(recordTime) when '4'  then  '4'  END ) AS '04' ,
  count(case HOUR(recordTime) when '5'  then  '5'  END ) AS '05' ,
  count(case HOUR(recordTime) when '6'  then  '6'  END ) AS '06' ,
  count(case HOUR(recordTime) when '7'  then  '7'  END ) AS '07' ,
  count(case HOUR(recordTime) when '8'  then  '8'  END ) AS '08' ,
  count(case HOUR(recordTime) when '9'  then  '9'  END ) AS '09' ,
  count(case HOUR(recordTime) when '10' then  '10' END ) AS '10' ,
  count(case HOUR(recordTime) when '11' then  '11' END ) AS '11' ,
  count(case HOUR(recordTime) when '12' then  '12' END ) AS '12' ,
  count(case HOUR(recordTime) when '13' then  '13' END ) AS '13' ,
  count(case HOUR(recordTime) when '14' then  '14' END ) AS '14' ,
  count(case HOUR(recordTime) when '15' then  '15' END ) AS '15' ,
  count(case HOUR(recordTime) when '16' then  '16' END ) AS '16' ,
  count(case HOUR(recordTime) when '17' then  '17' END ) AS '17' ,
  count(case HOUR(recordTime) when '18' then  '18' END ) AS '18' ,
  count(case HOUR(recordTime) when '19' then  '19' END ) AS '19' ,
  count(case HOUR(recordTime) when '20' then  '20' END ) AS '20' ,
  count(case HOUR(recordTime) when '21' then  '21' END ) AS '21' ,
  count(case HOUR(recordTime) when '22' then  '22' END ) AS '22' ,
  count(case HOUR(recordTime) when '23' then  '23' END ) AS '23' ,
  count(name) AS 总计  
	from tt_record
	where  1=1 
		and recordTime>= '2021-04-14 00:00:00' 
		and recordTime<= '2021-04-14 23:59:59'      
	group by name 
	WITH ROLLUP;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值