数据统计SQL

来源:互联网 发布:域名放godaddy 编辑:程序博客网 时间:2024/06/05 16:52
-- 查询当前这周的数据
-- ((ticketnumber - salenumber)*ticketactprice)
(100,100)*100

SELECT sum(ticketprice) FROM website_ticket_detail WHERE YEARWEEK(date_format(buytime,'%Y-%m-%d')) = YEARWEEK(now());

-- 查询上周的数据
SELECT name,submittime FROM WEBSITE_TICKET_INFO WHERE YEARWEEK(date_format(startdate,'%Y-%m-%d')) = YEARWEEK(now())-1;

-- 查询当前月份的数据

select * from business_apply where date_format(occurdate,'%Y-%m')=date_format(now(),'%Y-%m');

-- 查询距离当前现在6个月的数据
select name,submittime from enterprise where submittime between date_sub(now(),interval 6 month) and now();

-- 查询上个月的数据
select name,submittime from enterprise where date_format(submittime,'%Y-%m')=date_format(DATE_SUB(curdate(), INTERVAL 1 MONTH),'%Y-%m')


-- //放款成功数据

select orgid from acct_loan  where putoutdate='2017/02/21';

-- //个阶段成功数据

-- businessbelong, "LightAmountFlow", "0010"
-- 2016123000000008

-- 20170222103126429980644569711

select * from BUSINESS_APPLY where serialno="20170222103126429980644569711";
select * from BUSINESS_APPLY o,FLOW_TASK ft
where o.businessbelong="2016123000000008" and o.serialno=ft.objectno  and ft.flowno="LightAmountFlow" and ft.phaseno='0010'
and date_format(occurdate,'%Y-%m')=date_format(now(),'%Y-%m');
0 0