select mechdate, sum(settleAmount), sum(mechSeqId), sum(orderamount), sum(settleFee), sum(ROUND(rateAmount,2))
from (select substring(mechdate,1,6) as mechdate,
count(mechSeqId) as mechSeqId,
sum(orderamount) as orderamount,
sum(ORDERAMOUNT - CENTERFEE) as settleAmount,
sum(ORDERAMOUNT - (ORDERAMOUNT - CENTERFEE)) as settleFee,
sum(ORDERAMOUNT*0.0005) as rateAmount
from boc_payinfo
where PROCSTATE = '04' and ACCCHECKSTATE = '02' and mechno = "+mechNo + whereStr+"
group by mechdate) group by mechdate order by mechdate
[Err] 1248 - Every derived table must have its own alias
from 后面不就是一个大的子查询吗。。
报错信息 查一下是说派生的表必须有别名 group by mechdate) group by mechdate order by mechdate
在这里给你子查询出来的表 取个名字呗
select from
(
...
) t
这种()的查询要加一个别名
select count(*) from (select t.mechno,count(*) from (select * from boc_payinfo where 1=1 and mechDate >= '20161001' and mechDate <= '20161221' and PROCSTATE = '04' and ACCCHECKSTATE = '02') t, mp_merinfo m where t.mechno = m.mechno group by t.mechno)