消去重复项?为什么不行??
SELECT distinct sght.khdm,SUM(sghtsp.spsl) AS spsl, SUM(sghtsp.spdj) AS spje, sum(sghtsp.spdj/sghtsp.spsl) AS pjdj, spdj/SUM(sghtsp.spdj) AS xsb
FROM sght,sghtsp
where sght.hth=sghtsp.hth
group BY khdm,spdj
order by khdm
问题是想消去khdm相同的记录,加上spdj/SUM(sghtsp.spdj) AS xsb这条语句就不行,
非要在group by 中加入spdj。 怎么样解决这个问题,感谢!!