Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2006
    Posts
    1

    Unanswered: Grouping Resuls of a Query

    Hi,
    Bit of a frustrating question (on my part- hopefully not yours)

    I have a query which returns information about a table, which i then need to select from this. Is this possible?

    Q1 - select p.postID, t.threadID, t.threadTitle, p.created from post p, thread t where p.threadID = t.threadID and t.threadID = $tID and rownum = 1 order by created desc

    From this, I need to order all the rows obtained by the value in created.

    Hope I've explained properly/fully.

    Thanks in advance. Sarah

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    you already have what you want -- the ORDER BY clause
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Jun 2003
    Location
    West Palm Beach, FL
    Posts
    2,713

    Talking


    Well, just maybe if you remove the and rownum = 1 you may also get all the required rows.

    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  4. #4
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    If you are trying to retreave the last created row (using the created column) then do


    select postID, threadID, threadTitle, created
    from
    (select p.postID, t.threadID, t.threadTitle, p.created
    from post p, thread t
    where p.threadID = t.threadID
    and t.threadID = $tID
    order by created desc)
    where and rownum = 1;
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

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