Dear All
I have table as like below:
Code:ID Ref Name Type Sal ---------------------------------------- 1 1 A W 2000 2 1 B X 6000 3 1 C Y 3000 4 1 D Z 3000 5 2 K W 2000 6 2 D X 1000 7 2 D Y 1000 8 2 D Z 1000
I want result like this:
As per the group of "Ref" field, in case of "Type" W, X "Sal" column needs to get sum of both the rows and keep the other fields from W row.Code:ID Ref Name Type Sal ---------------------------------------- 1 1 A W 8000 3 1 C Y 3000 4 1 D Z 3000 5 2 K W 3000 7 2 D Y 1000 8 2 D Z 1000
In each Ref group (as like 1 or 2 in above data) there won't be duplication of "Type" field.
How can I create SQL statement for get this result.
All your help appreciated.
Regards
Somnath