Home » SQL & PL/SQL » SQL & PL/SQL » please solve this Query (oracle 8.2)
please solve this Query [message #295229] Mon, 21 January 2008 18:48 Go to next message
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 #295237 is a reply to message #295229] Mon, 21 January 2008 19:25 Go to previous messageGo to next message
ebrian
Messages: 2794
Registered: April 2006
Senior Member
Please read the forum guide prior to posting.

If you'd like us to help with your query you could at least show us some of the SQL you used to ATTEMPT to solve your question. In addition, some create table and insert statements would definitely help.

Help us help you!
Re: please solve this Query [message #295261 is a reply to message #295229] Mon, 21 January 2008 22:25 Go to previous messageGo to next message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member

Quote:
show us some of the SQL you used to ATTEMPT to solve your question


It looks like ebrian understood the question .

But I am afraid Confused , I didn't understand your question .
On what basis jan column value becomes 240 ? Is it AVERAGE Or SUM ?

Anyway Provide the Create and Insert statement .

Thumbs Up
Rajuvan
Re: please solve this Query [message #295262 is a reply to message #295261] Mon, 21 January 2008 22:34 Go to previous messageGo to next message
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..
Re: please solve this Query [message #295264 is a reply to message #295229] Mon, 21 January 2008 22:42 Go to previous message
rajavu1
Messages: 1574
Registered: May 2005
Location: Bangalore , India
Senior Member

It will Work , I hope.

Are you getting wrong answer for this query ?

Thumbs Up
Rajuvan.
Previous Topic: Recompile View to show the newly added columns
Next Topic: sum of distinct records data
Goto Forum:
  


Current Time: Sun Feb 09 23:45:38 CST 2025