mysql时间

where DATE_FORMAT(ndate,'%Y-%m')=date_format(DATE_SUB(curdate(), INTERVAL 1 MONTH),'%Y-%m')//上月统计
select "本日" ndate,sum(xj) xj,sum(kk) kk,sum(qk) qk,sum(hk) hk,sum(zdxh) zdxh,sum(hys) hys,sum(xks) xks,sum(yyxh) yyxh from tj_yingyetj where ndate = curdate()
select "昨日" ndate,sum(xj) xj,sum(kk) kk,sum(qk) qk,sum(hk) hk,sum(zdxh) zdxh,sum(hys) hys,sum(xks) xks,sum(yyxh) yyxh from tj_yingyetj where date(ndate)=date_sub(curdate(),interval 1 day);
select "本月" ndate,sum(xj) xj,sum(kk) kk,sum(qk) qk,sum(hk) hk,sum(zdxh) zdxh,sum(hys) hys,sum(xks) xks,sum(yyxh) yyxh from tj_yingyetj where date_format(ndate,'%y-%m')=date_format(now(),'%y-%m')
select "上月" ndate,sum(xj) xj,sum(kk) kk,sum(qk) qk,sum(hk) hk,sum(zdxh) zdxh,sum(hys) hys,sum(xks) xks,sum(yyxh) yyxh from tj_yingyetj where date_format(ndate,'%y-%m')=date_format(date_sub(curdate(), interval 1 month),'%y-%m')

你可能感兴趣的:(mysql)