Results 1 to 5 of 5

Thread: Typical Query

  1. #1
    Join Date
    Sep 2008
    Posts
    16

    Unanswered: Typical Query

    i have 2 columns in a tables as follows
    WK ID
    1 NULL
    3 1
    9 NULL
    10 NULL
    11 10
    12 10
    13 11
    14 11
    15 11
    16 11
    17 12
    18 12
    19 NULL
    20 19
    21 19
    22 20
    23 20
    24 20
    25 21
    26 21
    27 21

    now the out put i require is based on my id say 11 i should fetch all the corresponding wk ie 13,14,15,16 i shuld do that even for null
    so my table shuld look like
    wx id
    null 1 9 10 19
    1 3
    10 11 12
    11 13 14 15 16
    12 17 18
    19 20 21
    20 22 23 24
    21 25 26 27
    so how do i do this ??
    please help me
    and they wanted it in a sql query
    Last edited by skarri; 12-11-08 at 15:17.
    "TALK SENSE TO FOOL. HE CALLS U FOOLISH"

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >so my table shuld look like
    Why should it look like......?
    What is the logic behind the rows of values?


    http://www.orafaq.com/forum/m/365356/74940/#msg_365356

    Why is URGENT for me (or anyone) to solve this problem for you?
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

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

    Thumbs down Urgent

    Look to me like one of those URGENT homework assignments.

    Is it due tomorrow?

    Here is a hint: Search for "crosstab", "pivot table" and "rows to columns"
    The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb

  4. #4
    Join Date
    Sep 2008
    Posts
    16
    skarri>ed
    Wrote file afiedt.buf

    1 SELECT sw,
    2 LTRIM(MAX( SYS_CONNECT_BY_PATH ( id, ',')),',') EMP_STRING
    3 FROM
    4 (SELECT id,sw,
    5 row_number() OVER ( PARTITION BY sw ORDER BY rownum) rn
    6 FROM maxy)
    7 CONNECT BY sw = PRIOR sw
    8 AND rn = PRIOR rn+1
    9 START WITH rn =1
    10 GROUP BY sw
    11* ORDER BY sw
    12 ;

    SW EMP_STRING
    ---------- -------------------------------------------------------------------------------------
    1 3
    10 11,12
    11 13,14,15,16
    12 17,18
    19 20,21
    20 22,23,24
    21 25,26,27
    1
    see because i dont get it i post not because its a homework any way thanks for the hint i have solved this before hand
    and for mentioning URGENT i am sorry i wont repeat
    there is no one urgent about others work only enthusiasts to help
    Last edited by skarri; 12-11-08 at 16:26.
    "TALK SENSE TO FOOL. HE CALLS U FOOLISH"

  5. #5
    Join Date
    Dec 2008
    Posts
    59

Posting Permissions

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