View previous topic :: View next topic
|
Author |
Message |
rguhanath
New User
Joined: 16 Oct 2006 Posts: 81 Location: chennai
|
|
|
|
Hi,
I need to display the one executed query function result in another row. I have attached the requirement which is in EXCEL format. I am using SPUFI option in FILE-AID for the perticular table. Please help me to generate a query.
Thanks and Regards,
Nath. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Please DO NOT post attachments as not every one is able to open them. This reduces the number of people available to help you. |
|
Back to top |
|
|
rguhanath
New User
Joined: 16 Oct 2006 Posts: 81 Location: chennai
|
|
|
|
Hi,
Sorry for using attachment. Below i have given the requirement and details.
Code: |
TABLE
COL1 COL2 COL3 COST ID
-----------------------------------------------------------------------------
ABC DEF GHI 0 1
ABC DEF GHI 2.5 2
ABC DEF GHI 3.5 2
PQR STU VWX 0 1
PQR STU VWX 4.5 2
PQR STU VWX 5.5 2
----------------------------------------------------------------------------
REQUIRED RESULT FROM ABOVE TABLE
COL1 COL2 COL3 SUM(COST) ID
-----------------------------------------------------------------------------
ABC DEF GHI 6.00 1
PQR STU VWX 10.00 1
-----------------------------------------------------------------------------
Need the out put which are having the 'ID=1' with the summation of cost.
COL1,COL2,COL3 data is same for the set of ID numbers(1,2)
Assume the Table name as TABLE1
|
|
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
Code: |
select a.col1,a.col2,a.col3, sum(b.cost), a.id
from table1 A , table1 B
where a.id = 1 and b.id = 2
and a.col1 = b.col and a.col2 = b.col2 and a.col3 = b.col3
group by a.col1,a.col2,a.col3,a.id |
is one way
Code: |
select a.col1,a.col2,a.col3,
(select sum(b.cost) from table1 B where a.col1 = b.col and a.col2 = b.col2 and a.col3 = b.col3 and b.id = 2) as cost
, a.id
from table1 A where a.id = 1 |
is another
and there still are a few other ways to do this. |
|
Back to top |
|
|
|