I have a data in a table:
PK Ent_id Amt1 Amt2
1 500 10 30
2 500 20 30
3 510 200 200
I want to write a query which will sumup amt1 for ent_id and put that in amt2.
1. When there is only one row (ent_id), in which case amt2 should be same as amt1.
2. When there are more than one row(with same ent_id) it should sum that amount and put it in amt2 as shown above.
I am able to write 2 queries for these 2 diffenent cases
but I want to do it in one query.
Can someone help please ??
Thanks a lot.
Well, it would seem that you would want to store the total in the table where only Ent_ID is the key, but I'll give it to ya anyway :)
------T2.Ent_id = T1.Ent_id
Click Here to Expand Forum to Full Width