View previous topic :: View next topic |
Author |
Message |
yadav2005 Intermediate

Joined: 10 Jan 2005 Posts: 348 Topics: 144
|
Posted: Wed Jul 25, 2007 5:47 am Post subject: db2 query needed |
|
|
Hai All,
I have written a query which is retreiving data in the format below:
Code: |
SELECT TABLEA.A,TABLEB.B,TABLEB.C
FROM
TABLEA,TABLEB
WHERE TABLEA.X = TABLEB.Y
GROUP BY TABLEB.B,
TABLEA.A,
TABLEB.C
ORDER BY TABLEB.B;
A B C
---------+---------+---------+---------+---------+---------+---------+--
1 TOM 11.50
1 CHRIS 20.50
1 LUCY 15.00
1 LUCY 16.00
|
I want the output as below and the data is presumed to as i have specified
Code: |
A B C
---------+---------+---------+---------+---------+---------+---------+--
1 TOM 11.50
1 CHRIS 20.50
1 LUCY 31.00
|
Can anyone help me with the desired query ? |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Jul 25, 2007 6:24 am Post subject: |
|
|
yadav2005,
Try this untested code
Code: |
SELECT TABLEA.A
,TABLEB.B
,SUM(TABLEB.C)
FROM TABLEA
,TABLEB
WHERE TABLEA.X = TABLEB.Y
GROUP BY TABLEB.B
,TABLEA.A
ORDER BY TABLEB.B
;
|
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
yadav2005 Intermediate

Joined: 10 Jan 2005 Posts: 348 Topics: 144
|
Posted: Wed Jul 25, 2007 6:40 am Post subject: |
|
|
Kolusu,
Thanks for your reply and i am able to get the desired results. |
|
Back to top |
|
 |
|
|