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.
| Author |
Topic |
|
dainova
Starting Member
31 Posts |
Posted - 2010-01-04 : 04:14:34
|
| Hi,Being new to sql, I'm facing a task to create some 30+ totals lines from db each of them could be like: < SELECT SUM(VOLUME) FROM T1 WHERE CUST=CUST01 > and I need to go thru list of all Customers CUST01 - CUST40 (SELECT DISTINCT CUST FROM T1), is there any way to code this in loop in single SP, and get output in separate files (or line). I don't think that have 40 SPs is a right way.It's for SQLServer 2003. I also will appreciate opinioins how it could be done on Oracle.txDai |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-01-04 : 05:22:59
|
| SELECT CUST,SUM(VOLUME) FROM T1 GROUP BY CUSTMadhivananFailing to plan is Planning to fail |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-01-04 : 05:41:53
|
There is no SQL Server 2003, do you mean SQL Server 2000 or 2005 or 2008?To get this info just run:select @@version No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
dainova
Starting Member
31 Posts |
Posted - 2010-01-04 : 14:07:51
|
| to Webfred: Sorry, it's SQL Server 2000.to Madhivanan: Tx, Ideally I'll need to put each Totals in separate file, that's why was thinking about some looping. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-05 : 03:15:05
|
quote: Originally posted by dainova to Webfred: Sorry, it's SQL Server 2000.to Madhivanan: Tx, Ideally I'll need to put each Totals in separate file, that's why was thinking about some looping.
so you need each customers total exported to different files? does it need individual info also? |
 |
|
|
|
|
|
|
|