select transportid,stationid,trainnum-(select sum(admitnum) from jg where transportid=daily_report.transportid),profit from daily_report
having( select sum(admitnum) from jg where transportid=daily_report.transportid)<trainnum
关键在于聚合函数不能用where 判断,而要用having
having( select sum(admitnum) from jg where transportid=daily_report.transportid)<trainnum
关键在于聚合函数不能用where 判断,而要用having
having( select sum(admitnum) from jg where transportid=daily_report.transportid)<trainnum)
少了一个括号吧.