SQL SERVER 2008 QUERY
I have a table that consists of 12 columns as follows:
acct, addr1, addr2, addr3, addr4, addr5,
addr6, addr7, add8, zip, domicile, shares
What I need is to roll up the total shares into one row for duplicate
rows. The criteria is that addr1 through addr4 are identical which
determines that the row is a duplicate.
I tried this but it didnt work.
SELECT acct, na1, na2, na3,
na4, na5, na6, na7, na8,
zip, DOMICILE, sum(shares) as total_shares
FROM table_name
GROUP BY na1, na2, na3, na4 ORDER BY na1;
No comments:
Post a Comment