Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2003
    Posts
    6

    Unanswered: ORDER BY in DELETE Command

    Hi,
    I want to delete a row in the table which should be ordered by a coloumn and then delete the first row in that table. How does I can make this work? My SQL statement is
    "DELETE FROM EVENT_QUE (SELECT * FROM EVENT_QUE ORDER BY TRANSITION_TIMESTAMP) WHERE ROWNUM = 1";
    First I need to order the table by coloumn TRANSITION_TIMESTAMP and then I need to delete the first row.

    I am getting SQL command has not properly ended , Can any body make out what I am wrong here.

    Thanks
    LVM

  2. #2
    Join Date
    May 2003
    Posts
    87
    Do you want to delete the first row in the table or delete the row with the lowest TRANSITION_TIMESTAMP ?

    You dont have to order the table to delete the first row. Simply do this :
    Code:
    delete from event_que
      where TRANSITION_TIMESTAMP = 
      (select min(TRANSITION_TIMESTAMP) from event_que)
    /

  3. #3
    Join Date
    Jun 2003
    Posts
    6
    Thank you very much it did work.

    Lvm


    Originally posted by dbmadcap
    Do you want to delete the first row in the table or delete the row with the lowest TRANSITION_TIMESTAMP ?

    You dont have to order the table to delete the first row. Simply do this :
    Code:
    delete from event_que
      where TRANSITION_TIMESTAMP = 
      (select min(TRANSITION_TIMESTAMP) from event_que)
    /

Posting Permissions

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