Converting rows to columns using dynamic query.

I am trying to use the below code that I founnd on the web to conver rows to columns. the reason that I want to use dynamic query is that the number of rows are not know and changes.
declare
    lv_sql varchar2(32767) := null ;
begin
    lv_sql := 'SELECT Iplineno ';
    for lv_rec in (SELECT distinct vendor from bidtabs  where letting = '10021200' and call ='021')
    loop
        lv_sql :=   lv_sql
                    || CHR(10)
                    || ', MAX( DECODE( vendor, '
                    || chr(39)
                    || lv_rec.vendor
                    || CHR(39)
                    || ', bidprice, NULL ) ) as "'
                    || lv_rec.vendor
                    || '" ' ;
    end loop;
    lv_sql :=   lv_sql
                || CHR(10)
                || 'FROM bidtabs  where letting =  ''10021200''  and call =  ''021''  and lineflag = ''L''  '
                || CHR(10)
                || 'GROUP BY iplineno ;' ;
here is the result
BIDPRICE     CALL     IPLINENO     LETTING     VENDOR
9,585     021     0010     10021200     C0104        
1,000     021     0020     10021200     C0104        
1,000     021     0030     10021200     C0104        
17     021     0040     10021200     C0104        
5     021     0050     10021200     C0104        
11,420     021     0010     10021200     K0054        
1,100     021     0020     10021200     K0054        
1,100     021     0030     10021200     K0054        
5     021     0040     10021200     K0054        
3     021     0050     10021200     K0054        
8,010     021     0010     10021200     V070         
900     021     0020     10021200     V070         
1,320     021     0030     10021200     V070         
11     021     0040     10021200     V070         
3     021     0050     10021200     V070         
and here is the desired output
CALL     IPLINENO     LETTING      C0104              K0054              V070         
021     0010     10021200      9,585                     11,420                                   8,010
021     0020     10021200      1,000       1,100     900
021     0030     10021200      1,000     1,100     1,320
021     0040     10021200       17     5     11
021     0050     10021200      5     3     3

Here is the error message I am getting:
RA-06550: line 22, column 43:
PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<an identifier> <a double-quoted delimited-identifier>
<a bind variable> << close current delete fetch lock insert
open rollback savepoint set sql execute commit forall merge
pipe

Similar Messages

  • Converting rows to columns using t-sql

    Hi All,
    I have a table with 3 columns, let say ID1 , ID2, Flag
    My Source data looks like this..
    ID1    ID2       Flag
    1         1            0
    1         2            0
    1         3            0
    2         7            0
    2         8            1
    2         9            0
    4         5            0
    Now My output should look like this..
    ID1     Newcol1     NewFlag1     Newcol2     NewFlag2   Newcol3    NewFlag3
    1           1                    0                  
     2                   0                3                
    0
    2           7                    0               
        8                   1                9                
    0
    4           5                    0                  
     null               null            null              null
    Basically I want to convert rows to columns and to get above output I need t-SQL query.
    Thanks in advance
    RH
    sql

    You can do it by this query:
    declare @table table ( ID1 int, ID2 int, Flag int)
    insert @table values ( 1,1,0 ),( 1,2,0 ),( 1,3,0 ),( 2,7,0 ),( 2,8,1 ),( 2,9,0 ),( 4,5,0 )
    WITH cte1
    AS ( SELECT Id1 ,
    ROW_NUMBER() over (partition by ID1 order by ID1 ) as Sequence ,
    ID2 ,
    Flag
    FROM @table
    cte2
    AS ( SELECT Id1 ,
    ColumnTitle + LTRIM(RTRIM(STR(Sequence))) AS ColumnTitle ,
    ColumnData
    FROM cte1 UNPIVOT ( ColumnData FOR ColumnTitle IN ( [ID2], [Flag] ) ) AS UP
    SELECT Id1 ,
    [ID21] FirstID2 ,
    [Flag1] FirstFlag ,
    [ID22] SecondID2 ,
    [Flag2] SecondFlag ,
    [ID23] ThirdID2 ,
    [Flag3] ThirdFlag
    FROM cte2 PIVOT ( MAX(ColumnData) FOR ColumnTitle IN ( [ID21],
    [Flag1],
    [ID22],
    [Flag2],
    [ID23],
    [Flag3] ) ) PV
    If you want to know more detail, please visit my old article about this method:
    T-SQL: PIVOT Ordered pair Columns
    T-SQL e-book by TechNet Wiki Community
    My Blog
    My Articles

  • Rows ino Columns using BEX query

    I got DSO with declaration records. Every declaration can have several versions, say:
    DECLR_ID  VERSION   AMNT
    1111                 01         1000
    1111                 02         1100
    1111                 03         1500 
    1112                 01         5000
    1112                 02         4999
    I need a query to compare final version with corrections (previuos to last versions). The result table must look like this:
    DECLR_ID  VERSION   CORR_AMNT      FINAL_AMNT        DIFF
    1111                 01         1000                     1500                 500
    1111                 02         1100                     1500                 400
    1112                 01         5000                     4999                   -1 
    is it possible by query designer to get results like this by not using any InfoSet?

    Hi,
    There is one possible provided if the version are less,
    Create the restricted KF, for each version where in keep amount as common in all RKF. Then create the calculated KF again for getting the difference of Last version Restricted KF and starting Restricted KF and continue the same for remaining keeping the Last version Restricted KF as common.
    Hope this may work. Try it.
    Regards,
    Vishwa.

  • Convert rows to columns using t-sql

    Hi All,
    My source data looks like this..
    ID      Name    Rn
    1       Sam      1
    1       John      2
    1       Greg      1
    1       Smith     2
    1        Aron      1
    2       Brad       1
    2       Kevin      2
    2       Alex        1
    2       Jeff          2
    I need t-sql to get below output..Put Name into two columns, When Rn=1 Then Name1, When Rn=2 Then Name2.
     ID      Name1    Rn1  Name2    Rn2
      1       Sam        1       John       2
      1       Greg        1       Smith     2
      1       Aron        1        null      null
      2       Brad         1       Kevin     2   
      2       Alex          1       Jeff        2
    Thanks!
    sql

    to achieve this you need to have either 1. some unique key that can refer rn=1 and 2 for each person in each group or 2 . identity value column where, row number are enforce order of rn=1 and rn=2
    Vinay''s solution works until you have  do not have  last name for one row but have some data for the same group id
    like : 
    INSERT INTO #temp1(ID,Name,Rn) VALUES (1,'Sam',1)
    INSERT INTO #temp1(ID,Name,Rn) VALUES (1,'John',2)
    INSERT INTO #temp1(ID,Name,Rn) VALUES (1,'Greg',1)
    INSERT INTO #temp1(ID,Name,Rn) VALUES (1,'Smith',2)
    INSERT INTO #temp1(ID,Name,Rn) VALUES (1,'Aron',1)
    INSERT INTO #temp1(ID,Name,Rn) VALUES (1,'newfirstname',1)
    INSERT INTO #temp1(ID,Name,Rn) VALUES (1,'wronglastname',2)
    INSERT INTO #temp1(ID,Name,Rn) VALUES (2,'Brad',1)
    INSERT INTO #temp1(ID,Name,Rn) VALUES (2,'Kevin',2)
    INSERT INTO #temp1(ID,Name,Rn) VALUES (2,'Alex',1)
    INSERT INTO #temp1(ID,Name,Rn) VALUES (2,'Jeff',2)
    this would work but as said you need some key to identify uniquely.
    create table #Tmp (no int identity(1,1),ID int,Name varchar(20),Rn int)
    insert into #Tmp
    values
    (1,'Sam',1),
    (1,'John',2),
    (1,'Greg',1),
    (1,'Smith',2),
    (1,'Aron',1),
    (2,'Brad',1),
    (2,'Kevin',2),
    (2,'Alex',1),
    (2,'Jeff',2)
    Select distinct A.ID,A.Name,A.RN,B.NAme,B.Rn
    from(
    (select A.ID,A.Name,A.RN,A.no from #tmp A where A.rn=1) A FULL OUTER JOIN
    (select A.ID,A.Name,A.RN,A.no from #tmp A where A.rn=2) B on a.ID=B.id and A.no=B.no-1)
    drop table #tmp
    Hope it Helps!!

  • Finding minimum value in each row using dynamic query

    need to find the minimum and maximum value from each row using dynamic query
    [from curr] will be given as input
    Tuky

    DECLARE @t TABLE(a INT,b INT,c INT);
    INSERT @t VALUES(1,2,3),(9,8,7),(4,6,5);
    SELECT *
    ,      (   SELECT  MAX(val) 
               FROM    (VALUES (a)
                           ,   (b)
                           ,   (c)
                       ) AS value(val)
           ) AS MaxVal 
    ,      (   SELECT  MIN(val) 
               FROM    (VALUES (a)
                           ,   (b)
                           ,   (c)
                       ) AS value(val)
           ) AS MinVal 
    FROM @t;
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Converting Rows into Column in Oracle 10g

    Hi All,                    
    I m using Oracle Version 10.1.0.2.0 - Production                    
    I have requirement to convert rows into column wise as per the following:                    
    My Query is:                    
    WITH t                    
    AS ( SELECT 'A' AS x, 100 AS y FROM DUAL                     
    UNION ALL                    
    SELECT 'B',200 FROM DUAL                    
    SELECT X, Y                    
    FROM t;     
    X Y
    A 100
    B 200
    My Requirement is
    A B
    100 200
    So any one could help me that how I resolve this.
    Regards,
    Prasanta

    Dear frank,
    Thanks for your support,.
    It's working fine for static cases.If the first column is dynamic then how come i will resolve it.
    Example:
    Create table mytab (ID_C Varchar2(15),Value_N Number);
    Records Population into MyTab table is dynamic.
    Insert into mytab values('HO',5000);
    Insert Into mytab values('PG1',2400);
    Insert Into mytab values('PG2',3000);
    Insert Into mytab values('PG3',800);
    Commit;
    SQL> Select * From MyTab;
    IDC_ ValueN_
    HO 5000
    PG1 2400
    PG2 3000
    PG3 800
    Then My expected result will be as follows
    HO PG1 PG2 PG3
    5000 2400 3000 800
    Thanks and Regards,
    Prasanta

  • How to convert row into column

    Hi All,
    My oracle apps version is r12 and db is 10 and i am using Bi publisher version 10g.
    Is it possible to convert row into column in Rtf template,
    My Query is
    SELECT distinct pvs.vendor_site_code,sum(aia.invoice_amount)
    FROM ap_invoices_all aia, po_vendors po, po_vendor_sites_all pvs
    WHERE aia.org_id = pvs.org_id
    AND aia.vendor_id = po.vendor_id
    AND aia.vendor_site_id = pvs.vendor_site_id
    AND aia.org_id=204
    group by pvs.vendor_site_code
    And output is like this
    Vendor sitecode Invoiceamt
    EAM-ERS 79240
    STAR GATE - PAY 3245902.31
    UPS - HQ 10792040.9
    Like this
    So in template i need the output like this
    Vendor sitecode EAM-ERS STAR GATE - PAY UPS - HQ
    Invoiceamt 79240 3245902.31 10792040.9
    I tried to achieve the output using sql query but by hardcoding only i have achieved it, so i have tried to convert directly in RTF template.
    can any one tell me is it possible.
    And if new project is added from the front end ie(now the query will produce 4 rows but now in template i have created only three columns)
    Is it possible to add a new column dynamically.
    Can any one please guide me and tell me is there any example.
    Thanks & regards
    Srikkanth

    Take a look at this post: http://blogs.oracle.com/roller-ui/bsc/spider.jsp?entry=MT%3aENTRY%3a5001
    Thanks,
    Bipuser

  • How to convert rows to columns in sql server 2008

    How to convert rows to columns in sql server 2008 using the GROUP BY function? (only one query allowed)

    Lookup the Pivot transformation. From BOL:
    The Pivot transformation makes a normalized data set into a less normalized
    but more compact version by pivoting the input data on a column value. For
    example, a normalized Orders data set that lists customer name, product, and quantity purchased typically has multiple rows for any customer who purchased multiple products, with each row for that customer showing order
    details for a different product. By pivoting the data set on the product column, the Pivot transformation can output a data set with a
    single row per customer. That single row lists all the purchases by the customer, with the product names shown as column names, and the quantity shown as a value in the product column. Because not every customer purchases every product, many columns may contain
    null values.
    When a dataset is pivoted, input columns perform different roles in the pivoting process. A column can participate in the following ways:
    The column is passed through unchanged to the output. Because many input rows
    can result only in one output row, the transformation copies only the first
    input value for the column.
    The column acts as the key or part of the key that identifies a set of
    records.
    The column defines the pivot. The values in this column are associated with
    columns in the pivoted dataset.
    The column contains values that are placed in the columns that the pivot
    creates.
    Paul

  • How to convert rows into column

    Hi,
    can any one help me how to convert rows into column by pl/sql procedure.
    Thanks and Regards

    http://www.oracle.com/technology/oramag/code/tips2004/050304.html
    -- dropping the sample table if exists
    drop table rowstocol
    -- create sample table
    create table rowstocol ( name varchar2(20));
    -- Inserting rows into sample table
    insert into rowstocol values('Amit Zhankar');
    insert into rowstocol values('Piyu Yawalkar');
    insert into rowstocol values('Piyu Yawalkar');
    insert into rowstocol values('Ashish Ghelani');
    insert into rowstocol values('Aditi Zhankar');
    insert into rowstocol values('Tom Kyte');
    insert into rowstocol values('Oracle');
    -- Following query should be run to create a sql. This result sql should be run to convert rows to column.
    -- The following query uses just the tablename (whose data is to be converted) and name of the column (which is to be converted).
    -- Example taken here is table rowstocol, column name.
    SELECT cc
    FROM (select decode(rn ,1 ,'Select ',null) ||' MAX (CASE WHEN dr = '|| rownum||' THEN DECODE (rn,1, col1) END) '||
    decode(rn,maxr,' col1 from ','||'||chr(39)||','||chr(39)||'|| ') cc,rn,maxr
    from (SELECT ROWNUM rn,count(0) over() maxr FROM rowstocol) order by rn) trows
    union all
    select '(SELECT tabs.col1, DENSE_RANK () OVER (ORDER BY col1,rowid) dr,dense_rank() OVER (order by 1) rn
    FROM (SELECT NAME col1 FROM rowstocol) tabs ) group by rn' cc from dual;
    -- The result of this query will do the reqd conversion from row to column.
    -- Replace table rowstocol by your table, column name by your column.
    CC
    Select MAX (CASE WHEN dr = 1 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 2 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 3 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 4 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 5 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 6 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 7 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 8 THEN DECODE (rn,1, col1) END) col1 from
    (SELECT tabs.col1, DENSE_RANK () OVER (ORDER BY col1,rowid) dr,dense_rank() OVER (order by 1) rn
    FROM (SELECT NAME col1 FROM rowstocol) tabs ) group by rn
    Select MAX (CASE WHEN dr = 1 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 2 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 3 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 4 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 5 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 6 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 7 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 8 THEN DECODE (rn,1, col1) END) col1 from
    (SELECT tabs.col1, DENSE_RANK () OVER (ORDER BY col1,rowid) dr,dense_rank() OVER (order by 1) rn
    FROM (SELECT NAME col1 FROM rowstocol) tabs ) group by rn;
    COL1
    Aditi Zhankar,Amit Zhankar,Ashish Ghelani,Oracle,Oracle,Piyu Yawalkar,Piyu Yawalkar,Tom Kyte
    Edited by: bhooma on Jan 20, 2009 2:44 AM

  • How to convert rows into columns with decode function

    Hi,
    How to convert rows into columns with the help of decode function in oracle.
    thanks and regards
    P Prakash

    say
    col1 col2
    1 10
    2 20
    3 30
    then use
    select col1,
    sum(decode(col2,10,10)) "new1"
    sum(decode(col2,20,20))"new2"
    sum(decode(col2,30,30))"new3"
    from table_name
    group by col1;
    we used sum u can use ny function if wont u have to give the column name i.e col2 name also
    so i think u got it nw
    regards

  • How to convert rows to columns of a table?

    I want to convert rows to columns of a table..
    Query in SQL??

    965373 wrote:
    I want to convert rows to columns of a table..
    Query in SQL??PIVOT by Frank Help for a query to add columns
    PIVOT by TomK http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:766825833740

  • How to use dynamic query for Result table

    Hello Experts,
    I want to use dynamic query and then display the result in the assignment block.
    Using dynamic query BTQAct and BTQRAct and base on some search criteria i want tofilter and then append the result in the result table of that custom context node, and then it should display the result in the view in UI.
    SO can you please provide me the samplle code on how to use the dynamic query and append in the result table.
    Regards.

    Hi,
    Please find below sample code:
    data:  query         TYPE REF TO cl_crm_bol_dquery_service,
               result        TYPE REF TO if_bol_bo_col.
    DATA: lt_params       TYPE crmt_name_value_pair_tab,        
               lwa_params      TYPE crmt_name_value_pair.             
    query = cl_crm_bol_dquery_service=>get_instance( 'BTQAct' ). " Get instance of dynamic query
    Set general query parameter for maximum number of hits
          lwa_params-name = 'MAX_HITS' .
          lwa_params-value = '50'.
          APPEND lwa_params TO lt_params.
          query->set_query_parameters( it_parameters = lt_params ).
          query->add_selection_param( iv_attr_name = 'OBJECT_ID'
                                                    iv_sign      = 'I'
                                                    iv_option    = 'EQ'
                                                    iv_low       = <lv_objectid>
                                                    iv_high      = '' ). " Set your search criteria. Repeat this code if you have multiple parameters
    "You can find possible search options for a query object in  GENIL_BOL_BROWSER
    result ?= query->get_query_result(  ).   " Get result from your search query
    me->typed_context-> <your result context node>->set_collection( result ). 
    Here you will have to create a context node in your view which would refer to query result object like for BTQAct its BTQRAct                      
    Hope this helps.
    e Regards,
    Bhushan

  • How to use three part name with using dynamic query.

    Dear all, (sqlserver 2008 express r2)
    q1)following is showing error, is it possible to accomplish the task with out using dynamic query.
    DECLARE @A VARCHAR(100)
    DECLARE @A1 VARCHAR(100)
    SET @A='DB1'
    SET @A1='DBO'
    SELECT * FROM @[email protected]
    q2) table value function is not accepting dynamic query , is there any way to do this task.
    yours sincerley

    Certain parts in an SQL query like FROM tablename cannot be local variables. In such a case, dynamic SQL can be applied:
    http://www.sqlusa.com/bestpractices/dynamicsql/
    As noted above, more information needed to decide if dynamic SQL the correct solution in this instance.
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Design & Programming
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Convert rows into columns nad vice versa in 10g

    how to convert rows into columns in 10g??

    Qwerty wrote:
    see below for rows to column case
    SQL> WITH t as
    2      (
    3       SELECT 'US' test_string FROM DUAL UNION
    4       SELECT 'AMERICA'  FROM DUAL UNION
    5       SELECT'HOLLYWOOD'  FROM DUAL UNION
    6       SELECT 'WASHINGTON'  FROM DUAL
    7      )
    8      select ltrim (sys_connect_by_path(test_string,','),',') test_string
    9        from (
    10     SELECT row_number() over(order by test_string) rno, test_string
    11       FROM t)
    12       WHERE connect_by_isleaf = 1 and rownum=1
    13       connect by rno = prior rno+1;
    TEST_STRING
    AMERICA,HOLLYWOOD,US,WASHINGTONI hope you can do it for column to rows now.That's not really rows to columns. That's rows to a column, which is more commonly called string aggregation.
    Rows to columns (or pivot) is more like:
    SQL> ed
    Wrote file afiedt.buf
      1  WITH t as
      2       (
      3        SELECT 'US' test_string FROM DUAL UNION
      4        SELECT 'AMERICA'  FROM DUAL UNION
      5        SELECT'HOLLYWOOD'  FROM DUAL UNION
      6        SELECT 'WASHINGTON'  FROM DUAL
      7       )
      8  --
      9  select max(decode(rn,1,test_string)) as col_1
    10        ,max(decode(rn,2,test_string)) as col_2
    11        ,max(decode(rn,3,test_string)) as col_3
    12        ,max(decode(rn,4,test_string)) as col_4
    13* from (select test_string, row_number() over (order by test_string) as rn from t)
    SQL> /
    COL_1      COL_2      COL_3      COL_4
    AMERICA    HOLLYWOOD  US         WASHINGTON
    SQL>And columns to rows (or unpivot) is like:
    SQL> ed
    Wrote file afiedt.buf
      1  WITH t as
      2       (
      3        SELECT 'US' col_1, 'AMERICA' col_2, 'HOLLYWOOD' col_3, 'WASHINGTON' col_4 FROM DUAL
      4       )
      5  --
      6  select col_1 as col from t union all
      7  select col_2 from t union all
      8  select col_3 from t union all
      9* select col_4 from t
    SQL> /
    COL
    US
    AMERICA
    HOLLYWOOD
    WASHINGTONor...
    SQL> ed
    Wrote file afiedt.buf
      1  WITH t as
      2       (
      3        SELECT 'US' col_1, 'AMERICA' col_2, 'HOLLYWOOD' col_3, 'WASHINGTON' col_4 FROM DUAL
      4       )
      5  --
      6  select decode(rownum,1,col_1,2,col_2,3,col_3,4,col_4) as col
      7* from t, (select * from dual connect by rownum <= 4)
    SQL> /
    COL
    US
    AMERICA
    HOLLYWOOD
    WASHINGTON
    SQL>

  • Select Statement - How do i convert rows to columns

    Hi, i need your help please.
    i have three options: A, B, C in table T_OPTIONS (not more and not less, it is always 3)
    no i can assign articles to this option.
    Article 1, 2, 3, 4
    in the table it looks like this
    ARTICLE_ID T_OPTIONS
    1                   A
    1                   B
    2                   C
    3                    A
    3                    C
    But now i want to have a select statement which convert rows to columns, it has to look like this
    ARTICLE A B C
    1             x x
    2             x
    3             x   x
    Can you help me!?
    Edited by: Dila on 02.08.2012 01:52
    Edited by: Dila on 02.08.2012 01:53

    Dila wrote:
    Hi, i need your help please.
    i have three options: A, B, C in table T_OPTIONS (not more and not less, it is always 3)
    no i can assign articles to this option.
    Article 1, 2, 3, 4
    in the table it looks like this
    ARTICLE_ID T_OPTIONS
    1                   A
    1                   B
    2                   C
    3                    A
    3                    C
    But now i want to have a select statement which convert rows to columns, it has to look like this
    ARTICLE A B C
    1             x x
    2             x
    3             x   x
    Can you help me!?
    Edited by: Dila on 02.08.2012 01:52
    Edited by: Dila on 02.08.2012 01:53Read {message:id=9360002} and {message:id=9360005}
    SQL> ed
    Wrote file afiedt.buf
      1  with sample_data as
      2  (
      3  select 1 ARTICLE_ID,'A' T_OPTIONS from dual union all
      4  select 1, 'B' from dual union all
      5  select 2, 'C' from dual union all
      6  select 3, 'A' from dual union all
      7  select 3, 'C' from dual
      8  )
      9   select article_id,
    10         decode(sum(case
    11                      when t_options = 'A' then 1
    12                      else 0
    13                    end), 0, null,
    14                          'X') A,
    15         decode(sum(case
    16                      when t_options = 'B' then 1
    17                      else 0
    18                    end), 0, null,
    19                          'X') B,
    20         decode(sum(case
    21                      when t_options = 'C' then 1
    22                      else 0
    23                    end), 0, null,
    24                          'X') C
    25  from   sample_data
    26* group  by article_id
    SQL> /
    ARTICLE_ID A B C
             1 X X
             2     X
             3 X   X

Maybe you are looking for

  • Adobe Acrobat 9 Pro - "hierarchy" bookmark

    Hi, I called everyone possible to get help on this issue, including Adobe Tech support, I still couldn't get helped. I'm hoping someone here could help. I am merging multiple PDF files into one, making a single PDF file. (combine > combine files into

  • How do you make folders directly in your email on an iPad

    How do you make folders in your email on an iPad 2?

  • Can't locate to delete file...Need help...

    So my kid got a fisher price iXl toy which required that I download the drivers for the mac as it didn't come with a disc for the mac. I downloaded the file fine and launched it however the software wasn't able to connect to the fisher price server,

  • Applicatio​n windows maniplatin​g

    hi all i  made a application in labview .this contains three sub vis ie read write .when oan read event genrate  the read window open ,when write event genrate  write sub vi fornt panel is open.my question is after buid the aplication  when run appli

  • Create Error log table

    I am supposed to insert the records that are not uploaded to the main table into a error log table and email the users about the error records that was not inserted into the table. How am is supposed to do it ? I have few more questions. What is the