UPDATE Problem

Thread Solved

Join Date: Oct 2008
Posts: 23
Reputation: Roybut is an unknown quantity at this point 
Solved Threads: 0
Roybut Roybut is offline Offline
Newbie Poster

UPDATE Problem

 
0
  #1
Aug 20th, 2009
Hi,

I have a table which I want to update thus:

If d_date is has a value and b_date is 30 or more then set d_date as the min value already in d_date. I know that the WHERE EXISTS clause is wrong but I don't know how to make this work.


  1. UPDATE TABLE
  2. SET d_date =
  3. (
  4. SELECT MIN(d_date)
  5. FROM TABLE
  6. )
  7. WHERE EXISTS
  8. (
  9. SELECT FLOOR( MONTHS_BETWEEN (SYSDATE, b_date) / 12 )
  10. FROM agents
  11. WHERE FLOOR( MONTHS_BETWEEN (SYSDATE, b_date) / 12 ) >=30
  12. )
  13. AND d_date IS NOT NULL
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 23
Reputation: Roybut is an unknown quantity at this point 
Solved Threads: 0
Roybut Roybut is offline Offline
Newbie Poster

Re: UPDATE Problem

 
0
  #2
Aug 21st, 2009
Doh! I sorted it out myself:

  1. UPDATE TABLE
  2. SET d_date =
  3. (
  4. SELECT MIN(d_date)
  5. FROM TABLE
  6. )
  7. WHERE
  8. FLOOR( MONTHS_BETWEEN (SYSDATE, b_date) / 12 ) >=30
  9. AND d_date IS NOT NULL

I was making it more complicated than it was.
Last edited by Roybut; Aug 21st, 2009 at 9:57 am.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Oracle Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC