Please help to achieve this output

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • manionline
    New Member
    • Sep 2008
    • 1

    Please help to achieve this output

    The following is the query

    select a,b,count(1) count from tbl group by a,b order by a,b

    which will give the output like this

    a b count
    =============== ===============
    18 A 16
    18 B 6
    18 C 7
    18 D 9
    19 A 16
    19 B 6
    19 C 7
    19 D 9
    17 A 16
    17 B 6
    17 C 7
    17 D 9


    But I want the output in the following format based on the field b

    a count1 count2 count3 count4
    =============== =============== =============== ==
    18 16 6 7 9
    19 16 6 7 9
    17 16 6 7 9

    Any idea or help to achieve this?
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    try to use decode or case statment.

    Comment

    Working...