Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Posts
    1

    Unanswered: how to get values to print horizontally?

    Let's say I do this:

    select name, class from student;

    name class
    ---- -----
    John english
    John history
    John math
    John computer

    but now i want data (class field) to print horizontally like below. how do i do it?

    name class class class class
    ---- ------- ------- ------ --------
    John english history math computer

    thanks so much.

  2. #2
    Join Date
    Oct 2003
    Location
    Dallas
    Posts
    76
    well I know no simple answer.

    but if you know the different type of classes you could do a case, or you could build a table then update it.

    select user,
    class1 = case when class = 'ENGLISH' then class else 'NONE' end,
    class2 = case when class = 'MATH' then class else 'NONE' end,
    class3 = case when class = 'HISTORY' then class else 'NONE' end,
    class4 = case when class = 'COMPUTER' then class else 'NONE' end
    from TABLE

    That is not that great of a solution, but maybe point you in a direction to get started.

  3. #3
    Join Date
    Nov 2003
    Location
    Bangalore,India
    Posts
    51

    Re: how to get values to print horizontally?

    you can use command like
    select 1,(select class from) as firstfield,(select ....) secondfield......
    from dual

    it works if you have the fixed number of classes....Otherwise also you can construct through pl/sql .
    Better soln would be create a table and insert the values before running the report

Posting Permissions

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