1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Oracle Select Query Result In Horizontal Format

Discussion in 'SQL PL/SQL' started by hyilmaz, Dec 8, 2012.

  1. hyilmaz

    hyilmaz Active Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    55
    hi, this instance multiple tables (for example, 3 tables) how-to.

    thanks
     

    Attached Files:

  2. Bharat

    Bharat Community Moderator Forum Guru

    Messages:
    1,747
    Likes Received:
    147
    Trophy Points:
    1,805
    Location:
    Vijayawada, India
    Hi Hyilmaz,

    What that attached .xls file related to?? Couldn't understand what are they..

    Please explain the things in clear steps. There is no relation between excel sheet and what you have shown in screenshots and title of this post.

    Note:- Please make sure that before posting everything should be in clear manner. By that everyone can understand.
     
    hyilmaz likes this.
  3. hyilmaz

    hyilmaz Active Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    55
    hi,
    I'm running a SQL query. This query data from a table'm having 3 different. Returns 18 rows results. Desired, to conclude this 18-row side by side.
    how can i get sql query result in horizontal way.

    screenshots 1...
    example sql query

    screenshots 2...
    results from our database

    excel sheet...
    the desired result, the horizontal
     
  4. hyilmaz

    hyilmaz Active Member

    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    55
    also tried to explain with an example.
     

    Attached Files:

  5. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
    On how many it was possible to guess according to three enclosed pictures and the excel file, you need to use PIVOT, if the oracle 11g version.

    link to documentation:

    oracle.com/technetwork/articles/sql/11g-pivot-097235.htm

    for oracle of prior 11g versions, at creation of a script it is possible to use group by and the decode function if the quantity of lines is known.

    link to a forum:

    orafaq.com/forum/t/92192/2/

    sql prototype:

    Code (SQL):
    SELECT *
      FROM (SELECT job,
                    SUM (decode (deptno, 10, sal)) DEPT10,
                    SUM (decode (deptno, 20, sal)) DEPT20,
                    SUM (decode (deptno, 30, sal)) DEPT30,
                    SUM (decode (deptno, 40, sal)) DEPT40
               FROM scott.emp
           GROUP BY job)
    ORDER BY 1;
     
  6. krasnoslobodtsev_si

    krasnoslobodtsev_si Forum Genius

    Messages:
    626
    Likes Received:
    129
    Trophy Points:
    810
    Location:
    Russian Federation
    Hi, Hyilmaz.
    You can show the text of sql of query?