Results 1 to 4 of 4

Thread: SQL output

  1. #1
    Join Date
    Aug 2008
    Posts
    464

    Unanswered: SQL output

    Hi guys
    I have a table containing daily values of names and numbers like:

    Code:
    DATETIME(Date),               NAME (VARCHAR2), SHOTS (NUMBER)
                 21/04/2013        A                        56
                 21/04/2013        B                        58
                 21/04/2013        C                        60
                 20/04/2013        A                        49
                 20/04/2013        B                        49
                 20/04/2013        C                        71
                 19/04/2013        A                        88
                 19/04/2013        B                        55
                 19/04/2013        C                        40
    I'm trying to create an output of the format:
    Showing the number of shots played in desc order for the last 3 days displayed as below:

    E.g,
    Code:
    DATE        NAME  SYSDATE-1  SYSDATE-2  SYSDATE-3  
    20/4/13      B         number        number        number             
    18/4/13      A         number        number        number            
    19/4/13      C         number        number        number
    But can't quite get the syntax.

    Something like :
    Code:
    SELECT DATE, NAME, SHOTS FROM TABLE order by shots DESC
    where datetime=trunc(sysdate)-1
    union
    SELECT DATE, NAME, SHOTS FROM TABLE order by shots DESC
    where datetime=trunc(sysdate)-2
    union
    SELECT DATE, NAME, SHOTS FROM TABLE order by shots DESC
    where datetime=trunc(sysdate)-3
    NOTE: Above SQL does not display the dates side by side.

    Any chance someone can advise?

    Regards
    Shajju

  2. #2
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Never mind. No complete solutions for homework
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  3. #3
    Join Date
    Aug 2008
    Posts
    464
    This is not homework.

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

    Cool

    Quote Originally Posted by shajju View Post
    Hi guys
    I have . . . E t c . . .
    Any chance someone can advise?
    Perhaps your Google is broken, here, use mine: Google
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

Posting Permissions

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