mysql常用函数

SELECT FROM_UNIXTIME(1234567890, '%Y-%m-%d %H:%i:%S')
SELECT count(1)num, FROM_UNIXTIME(create_time/1000,'%Y-%m-%d %H')time
 from mytable

 

SELECT *  FROM mytable where pay_company_id='201703231339'
and create_time>=UNIX_TIMESTAMP('2017-07-31')*1000
and create_time<UNIX_TIMESTAMP('2017-08-28')*1000
and order_status=5

例如统计表一段时间内 中支付成功率

SELECT count(1) 总数,  count(if(pay_status='1',true,null )) as 支付成功数,
count(if(pay_status='1',true,null )) /count(1) 支付成功率
from mytable where 
create_day=20170617 and  pay_platform=10
and create_time >=UNIX_TIMESTAMP('2017-06-17 11:00')*1000 
and create_time <=UNIX_TIMESTAMP('2017-06-17 12:55')*1000 ;  

 

发表评论

邮箱地址不会被公开。