sql语句编写能力很差啊,总不用就忘啊,用了聚合函数的查询,得有group by
第一个行,第二个不行
SELECT
(select rowname from RPT_ROWCODE_SERVCORP rs where rs.rowcode = r.rowcode and tname = 'RPT_AGG_ST_SERV_01_2007') rowname,
r.rowcode,
sum(r.N01),sum(r.N02),sum(r.N03),sum(r.N04),sum(r.N05),sum(r.N06),sum(r.N07),
sum(r.N08),sum(r.N09),sum(r.N10),sum(r.N11),sum(r.N12),sum(r.N13),sum(r.N14),sum(r.N15)
FROM RPT_AGG_ST_SERV_01_2007 r
WHERE r.offino in ('0001') group by r.rowcode
order by r.rowcode
SELECT
rrs.rowcode,rrs.rowname,
sum(r.N01),sum(r.N02),sum(r.N03),sum(r.N04),sum(r.N05),sum(r.N06),sum(r.N07),
sum(r.N08),sum(r.N09),sum(r.N10),sum(r.N11),sum(r.N12),sum(r.N13),sum(r.N14),sum(r.N15)
FROM RPT_AGG_ST_SERV_01_2007 r,RPT_ROWCODE_SERVCORP rrs
WHERE rrs.rowcode = r.rowcode and rrs.tname = 'RPT_AGG_ST_SERV_01_2007' and r.offino in ('0001') group by r.rowcode
order by r.rowcode