SELECT JBGS.XMID, SUM(JBGS.JBGS * JBYXXS.YXXS) / (SELECT SUM(B.GS) FROM T_XMCBHZ B WHERE B.XMID=‘ ” + XMID + ” ‘)
FROM (SELECT MIN(B.XMID) XMID, B.RYJB, SUM(B.GS) JBGS FROM T_XMCBHZ B WHERE B.XMID=‘ ” +XMID + ” ‘ GROUP BY RYJB) JBGS,
(SELECT MIN(B.XMID) XMID, B.RYJB, MIN(B.YXXS) YXXS FROM T_XMCBHZ B WHERE B.XMID=‘ ” + XMID + ” ‘ GROUP BY RYJB ) JBYXXS WHERE JBYXXS.RYJB=JBGS.RYJB
GROUP BY JBGS.XMID,JBYXXS.XMID
最后数据其实就是一个字段,一条数据,为什么要在最后加上一个
GROUP BY JBGS.XMID,JBYXXS.XMID
我猜测可能是两表之间的关联问题,明天解决!
时间: 2024-10-07 11:00:13