Urgent query help please
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Urgent query help please

  1. #1
    Join Date
    Jan 2001
    I have a data in a table:
    Called temp

    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.


  2. #2
    Join Date
    Nov 2000
    Baltimore, MD USA
    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 :)

    --Temp T1
    --T1.Amt2 =
    ------Temp T2
    ------T2.Ent_id = T1.Ent_id


    - Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width