Results 1 to 2 of 2

Thread: Writing an Update Query?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Writing an Update Query?

    I am not good at writing SQL queries. What I need to do is update a table that has quite a few rows in it. Here is the gist of what I need to do.

    Update tblRR_Detail
    if status_id = 1 then
    nri_amt = rent_amt - uw_rent_amt
    else if status_id = 2 then
    nri_amt = rent_amt - rent_amt - uw_rent_amt
    Where RRID = 23

    I have NO idea how to code this using SQL.

    Please help...I am under a 1 hour time constraint!

    Thanks,
    Blake

  2. #2
    Frenzied Member
    Join Date
    May 2006
    Location
    some place in the cloud
    Posts
    1,886

    Re: Writing an Update Query?

    Try:
    Code:
    UPDATE tblRR_Detail
    SET nri_amt  = 
        ( CASE
             WHEN status_id = 1 THEN rent_amt - uw_rent_amt
             WHEN status_id = 2 THEN rent_amt - rent_amt - uw_rent_amt
           END
        )
    WHERE RRID = 23
    JG

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