Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 how to rollover data from zipcode to state...

Author  Topic 

sql4us
Starting Member

24 Posts

Posted - 2011-09-19 : 13:27:56

I have zipcode data (around 60,K records). I want to roll over by state:
for example:
State zipcode val1 val2 val3 val4
CA 90001 10 20 30 40
CA 90002 50 20 35 22
CA 90003 10 3 20 40
......

Results
State val1 val2 val3 val4
CA 70 43 85 102
AK
AL....

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2011-09-19 : 13:29:54
How about something like;

SELECT 	state, 
SUM(val1) val1,
SUM(val2) val2,
SUM(val3) val3,
SUM(val4) val4
FROM <table>
GROUP BY state
Go to Top of Page

sql4us
Starting Member

24 Posts

Posted - 2011-09-19 : 14:26:37
quote:
Originally posted by ehorn

How about something like;

SELECT 	state, 
SUM(val1) val1,
SUM(val2) val2,
SUM(val3) val3,
SUM(val4) val4
FROM <table>
GROUP BY state




Thanks ehorn!
Go to Top of Page

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2011-09-19 : 14:28:04
yvw,

Have a nice day.
Go to Top of Page
   

- Advertisement -