1、-- if 只能替换一个值
select if(operation_type=3 ,‘赎回’,operation_type) as 类型,count() as 数量 from mine_pool_order where DATE_SUB(CURDATE(), INTERVAL 7 DAY)+4 <= created_time and pool_id=12
GROUP BY operation_type
order by 数量 desc
2、-- CASE—when—else查询数据查询出的内容进行替换
select CASE operation_type
WHEN 1 THEN
‘锁仓’
WHEN 2 THEN
‘提取’
WHEN 3 THEN
‘赎回’
WHEN 4 THEN
‘质押’
ELSE
‘冻结’
END operation_type ,count() as 数量 from mine_pool_order
where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= created_time
and user_id not in(142,143,141,140)
GROUP BY operation_type
order by 数量 desc
3、-- 修改成如下这种形式可以 as 重命名字段值 ,上面不行。
select (CAS