一些有意思的sql

select
   user_id  userId,
  type type,
  case when type='1' then concat( '订单支付',money,'')
   when type='2' then concat( '预存充值',money,'')
   when type='3' then concat( '退款',money,'')
  when type='4' then  concat('提现',money,'')
  when type='5' then concat( '收入',money,'')
  when type='6' then  concat('教练球童',money,'')
  when type='7' then concat( '打赏球童',money,'')
  when type='8'  then concat( '买单',money,'')
  when type='9' then  concat('支付愿望',money,'')
  when type='10' then  concat('红包',money,'')
  when type='11' then  concat('预存赠送',money,'')
  else
   concat('其他',money,'')
  end  typeText,
  create_time createTime,
  out_in outIn,
  money money,
  case when out_in ='1' then concat('+','',money)
  else concat('-','',money)
  end
    moneyText
  from ef_jiaoyi_huizong
  where user_id = #{userId,jdbcType=BIGINT}
  ORDER by create_time DESC
  LIMIT #{pageNo},#{pageSize}
 


用 DATE_FORMAT 来格式化日期字段



SELECT DATE_FORMAT(crt_time,'%Y-%m-%d'FROM ad_n_advertise_t

CAST函数用于将某种数据类型的表达式显式转换为另一种数据类型。CAST()函数的参数是一个表达式,它包括用AS关键字分隔的源值和目标数据类型。 
CAST (expression AS data_type); 
decimal(a,b) 
a指定指定小数点左边和右边可以存储的十进制数字的最大个数,最大精度38。 
b指定小数点右边可以存储的十进制数字的最大个数。小数位数必须是从 0 到 a之间的值。默认小数位数是 0。

SELECT

cast(avg(eps.score) as decimal(10,1))score
FROM
ef_product_score eps
WHERE
eps.product_id = 1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值