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))scoreFROM
ef_product_score eps
WHERE
eps.product_id = 1