我有一个包含 12 列的表,如下所示:
acct, addr1, addr2, addr3, addr4, addr5,
addr6, addr7, add8, zip, domicile, shares
我需要的是将总数汇总shares
到一行中以重复行。标准是addr1
通过addr4
是相同的,这确定该行是重复的。
我试过这个,但它没有用。
SELECT acct, addr1, addr2, addr3, addr4, addr5,
addr6, addr7, add8,
zip, DOMICILE, sum(shares) as total_shares
FROM table_name
GROUP BY addr1, addr2, addr3, addr4 ORDER BY addr1;