please solve this Query [message #295229] |
Mon, 21 January 2008 18:48  |
mohapatra
Messages: 24 Registered: August 2006 Location: New Jersey
|
Junior Member |
|
|
i ve a table volume
serial_no code jan feb march april may june july ....Dec
12356 1001 215 100 300 120 100 .. ...
15153 1001 225 200 700 210 150 .. ...
32456 1002 120 300 780 340 160 .. ...
13356 1002 230 500 560 450 170 .. ...
12454 1002 234 200 605 550 400 .. ...
12356 1003 215 100 300 120 100 .. ...
15153 1003 225 200 700 210 150 .. ...
32456 1003 120 300 780 340 160 .. ...
13356 1003 230 500 560 450 170 .. ...
12454 1003 234 200 605 550 400 .. ...
----
32456 1005 240 .. .. ... ..
there is another code 1005 which is sum of 1001, 1002 and 1003
So for wach serial_no , the jan data should be 240.
|
|
|
|
|
Re: please solve this Query [message #295262 is a reply to message #295261] |
Mon, 21 January 2008 22:34   |
mohapatra
Messages: 24 Registered: August 2006 Location: New Jersey
|
Junior Member |
|
|
Mr Ebrian ,
Thanks for your advise. I tried it and apologize for not giving suficient data.
I have tried like below.
Insert into tableA
select serial_no ,1005, sum(jan), sum(feb), sum(mar)....
from tableA
where code in (1001, 1002, 1003)
group by serial_no
is there any other efficient way...as i m not sure if it ll work or not.
becuase there may not be same no of rows for each code for a particular serial_no's .for example code 1001- there can be more no of rows than for code 1002..
|
|
|
|