| Author |
Topic  |
|
|
RammohanB
Starting Member
India
9 Posts |
Posted - 11/30/2012 : 14:29:53
|
select SUM(A.price),B.bid,C.name from prices A JOIN sal B ON B.id=A.id JOIN persons C ON C.name= B.name WHERE a.date = '2012-11-29' group by bid,name --- i am using above query but i am wrong values, i am getting sum(price) for the date for one id in one row . how can i get instead of two three rows to single row...i have multiple names having different ids but i need all ids prices in single row using name
Rammohan |
|
|
shilpash
Yak Posting Veteran
75 Posts |
Posted - 11/30/2012 : 14:40:39
|
SELECT SUM(A.price) ,B.bid FROM prices A JOIN sal B ON B.id = A.id WHERE a.date = '2012-11-29' GROUP BY b.bid
|
 |
|
|
RammohanB
Starting Member
India
9 Posts |
Posted - 11/30/2012 : 14:43:31
|
It worked thank you very much
Rammohan |
 |
|
|
RammohanB
Starting Member
India
9 Posts |
Posted - 11/30/2012 : 14:46:17
|
And also i want name too in my select list which is common in persons and bid
Rammohan |
 |
|
|
shilpash
Yak Posting Veteran
75 Posts |
Posted - 11/30/2012 : 15:25:27
|
WITH PriceCte AS (SELECT SUM(A.price) price ,B.id FROM prices A JOIN sal B ON B.id = A.id WHERE a.date = '2012-11-29' GROUP BY b.bid ) SELECT p.person ,p.id ,t.price FROM persons p LEFT JOIN PriceCte T ON T.id = p.id |
 |
|
|
shilpash
Yak Posting Veteran
75 Posts |
Posted - 11/30/2012 : 15:30:21
|
WITH PriceCte AS (SELECT SUM(A.price) price ,B.id FROM prices A JOIN sal B ON B.id = A.id GROUP BY b.bid ) SELECT p.person ,p.id ,t.price FROM persons p LEFT JOIN PriceCte T ON T.id = p.id WHERE P.date = '2012-11-29'
|
Edited by - shilpash on 11/30/2012 15:31:04 |
 |
|
| |
Topic  |
|