Select-> how to convert rows to columns

Hi, I need your help please.

I have three options: A, B, C in table T_OPTIONS (no more, no less, it's always 3)

No I can assign items to this option.
Section 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 that transform the lines in columns, it should look like this

A, B AND C OF ARTICLE
1             x x
2             x
3             x   x


Can you help me!?

Published by: Dila on 02.08.2012 01:52

Published by: Dila on 02.08.2012 01:53
SQL> with t as (
  2  select 1 article_id, 'A' options from dual union
  3  select 1,'B' from dual union
  4  select 2,'C' from dual union
  5  select 3,'A' from dual union
  6  select 3,'C' from dual
  7  )
  8  --
  9  --
 10  --
 11  select article_id article
 12  ,      max(case when options = 'A' then 'x' end) A
 13  ,      max(case when options = 'B' then 'x' end) B
 14  ,      max(case when options = 'C' then 'x' end) C
 15  from   t
 16  group by article_id
 17  order by article_id;

   ARTICLE A B C
---------- - - -
         1 x x
         2     x
         3 x   x

3 rows selected.

Tags: Database

Similar Questions

  • How to turn rows into columns

    Suppose I have the following table:

    FIELD1 FIELD2 FIELD3
    a desc1 5
    a 10 desc2
    desc1 b 3
    b desc3 6
    desc4 c 2
    ...

    I would like to write a query, get the following result in order not to get a dulpication for Field1:

    FIELD1 DESC1 DESC2 DESC3 DESCS4
    a 10 5
    3 6 b
    a p
    ...

    Can you help me?
    Thanks in advance

    Mark

    Hello
    This link can help you:
    http://saadnayef.blogspot.com/2010/05/converting-rows-to-columns-and-Vice.html

    Saad,

  • How to Exchange rows and columns where to access the paper web in html IE

    Hi all!

    I use web analytics studio Oracle hyperion with Version: 11.1.1.2.0.940. Design of web document analysis, I use the spreadsheet, then turn to the analysis view, I can swap the row and column position by dragging and pulling.

    But when I access the document by the smartcut in ie browser, opening in the html template, how can I exchange line and column position?

    Thank you very much in advance.

    OK, I think I understand what you're saying. The problem is that it does not show the left pane with a smartcut.

    Here's a tip. Add a button of 'Service '. Add "Information Toggle Pane" as the service.

    When you click the button that will open the left handle in HTML view panel. You will then see row and column and you should be able to switch the dimensions as needed. I just tested and it works.

    hope that helps.

  • How to convert a single column in the primary key column

    Hi all

    I have a column that's unique cnstraint, this column contains the value as digital and also null.

    So how do you convert to primary key column

    Concerning
    Prashant

    Prashant wrote:
    Hi all

    I have a column that's unique cnstraint, this column contains the value as digital and also null.

    So how do you convert to primary key column

    Concerning
    Prashant

    Prashant,

    You must assign new values to null values. You can use a sequence to produce the figures in this column.

    Select max (your_unique_column) from your_table; -find the maximum value of this column, so you can start the sequence of this number.

    create sequence seq_for_your_table with XXXX - value max + 1 you have found

    Update your_table set your_unique_column = seq_for_your_table.nextval () where your_unique_column is null

    You can create a primary key on this column.

    Best regards

    Grosbois

    -------------------------------------------------------
    If you answer this question, please mark appropriate as correct/useful messages and the thread as closed. Thank you

  • Convert rows into columns

    Hi guys,.

    It is requirement of the sample. How to get there... did someone met before...

    Thank you...

    Hello

    Just to clarify what Gianni Ceresa said below is how you can do in OBIEE. In the column C2 add below the formula in the column edit replace C2 by your column of presentation.

    EVALUATE_AGGR ('LISTAGG (%1, %2) WITHIN THE GROUP (ORDER BY DESC %3)', C2, ",", C2)

    If it gives an error set up the tank column.

    Thank you

    RAM

  • Rows of columns

    Hello

    I have a query of the following type:

    SELECT ID, COLUMN_LABEL, VALUE OF METRICS

    For each ID, there is a label and a value:

    1 TEST OF 100

    1 DAY 17/07/2015

    1. sign /tmp/log.txt

    TEST2 2 100

    2 DAY 16/07/2014

    2 LOG /tmp/log_2.txt

    How can I ensure, for each get KEY_ID n VALUES in the form of columns of a row with the position of the columns as COLUMN_LABEL? It looks like this

    KEY_ID TEST DATE LOG

    1 100 /tmp/log.txt 17/07/2014

    2 100 tmp_log2.txt 16/07/2014

    Thanks for your help

    Hello

    This is called swivel.  The forum FAQ has a page dedicated to it.  See: Re: 4. How can I convert rows to columns?

    If you get stuck, post your best attempt, with CREATE TABLE and INSERT statements for your sample data and accurate results, you want to start from these data (otherwise what you have already posted).  See: Re: 2. How can I ask a question on the forums?

  • How can I insert a number to a specific index (row and column) to a table

    I had the most with function 'insert into array' problem because of its counter-intuitiveness. I want to insert a number I got inside a loop IN a table. The ROW and COLUMN of this table I want enter the number is specified by the number of loops of two loops FOR. It did not work.

    So, I have isolated and tested this function further. Frankly, I initialized a table 2D with ZEROS and plugged into the "insert into array" function (on top of entry). I then put the number '1' for the index (line) and the number "2" for the index (column) and then put the entry number "6" for the "new item/sub-table. Then, I hung a picture of 2-D (indicator) output to the output of the function "insert into array. When I did all that, it means I want to just put the number '6' in line '1' and the column '2'... This isn't letting me do it.

    How can I do this SIMPLE?

    Hi Darrell h...,

    Looks like you can use the function "autoindexing. Take your value and connect it to your loop, it will be a default autoindexing. Right-click on the last tunnel of output and select Create indicator, the result is your table.

    It will be useful.

    Mike

  • ADF: How to convert column ADF output text to link to the item in the table?

    Hello world

    I use Jdev 11 G.

    I dragged VO as adf read only the table that is to have 10 columns.
    now my requirement is to convert the first column "empid" to link the item.
    How can I convert this column as a link?

    and one more thing by clicking on this link, we should sail to OAF page from empid as parameter.
    How can I achieve this?

    Any answer will be really useful.

    Thank you.

    In my opinion, using af: goLink is the right option when you call a page of the outsider.
    you do not download workspace sample & test it provided link?
    You can select yr af:commandLink in the Structure window & do a right click to select "create a binding of the action method.
    In the open dialog box you can choose the "connection method" & then name the bean with the same method name generated by the IDE.

  • How to convert the column lines

    I need to convert my output lines of sql for the column as a pivot to 11g

    Please give me the example of this

    check out this link

    http://nimishgarg.blogspot.com/2010/06/Oracle-pivot-data-rows-to-columns.html

    request for 10g would be

    Select *.
    (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
    Working Group)
    order by 1;

  • How to get the string (specified by row and column) of txt file with labview

    Hello world

    How to get the string (specified by row and column) of txt file with labview

    THX

    As far as I know, a text file has no column.  Be more specific.  Do you mean something like the 5th word on line 4, where the words are separated by a space, and lines are separated by a newline character?  You can read from the spreadsheet String function and set the delimiter to a space.  This will produce a 2D channels table.  Then use the table to index and give the line number and column number.

  • How to convert a timestamp varchar2 column (3)

    Hi all

    I have a column of field date with varchar2 data type:

    Date
    ----------
    13/03/2011 10:22
    13/03/2011 10:22


    I tried this:
    select to_timestamp(date,'HH24MI') from dual;
    IAM getting this error:

    ORA-01858: a non-digit character was found here where was waiting for a digital
    I want to convert date timestamp column (3) column

    846773 wrote:

    I want to convert date timestamp column (3) column

    TIMESTAMP is not time column. Look at him as a date with a better accuracy - it supports the franctional part of a second. In any case, use:

    Select to_timestamp (date, "DD/MM/YYYY HH: mi AM'") twice;

    SY.

  • How to create the table with the rows and columns using the layout?

    One of my friends advised me to put my site on the mode of provision as it is better than the standard as he said
    but I couldnot make an ordinary table with the rows and columns in mode available th
    y at - there someone who can tell me how to?
    Thank you very much

    Wednesday, April 18, 2007 21:01:38 + 0000 (UTC), "Mr.Ghost".
    wrote:

    > A friend of mine advised me to put my whole site on the mode of disposal as its
    > better than standard, as he says

    Your friend won't. Don't listen to him any more. Mode of disposal creates
    very fragile and rigid code pauses at the first opportunity.

    Gary

  • How to change the rows and columns of newtabs?

    I can't change the rows and columns to mozilla version 33

    From topic: config browser.newtabpage.columns shows 5 by default, but these 5 columns appear not only 3 as before. Don't know why, but I use generally not even the default new tab page in my profile daily.

    Still works this - https://addons.mozilla.org/en-US/firefox/addon/new-tab-tools/ - extension to change the page of newTab via a user accessible interface name in the Addons, rather than routing autour Manager inside Firefox. I use this add-on in a second profile that I use for my favorite sites

  • How to convert my toolbar in 2 rows so that all my icons and apps to show?

    How to convert my toolbar so that it appears on two lines?

    Hello

    1. which version of the Windows operating system is installed on your computer?

    2. are you referring to the toolbar or the task bar?

    3. If you are referring to the Internet Explorer toolbar, which version of Internet Explorer is installed on your computer?

    If you are referring to the taskbar, then try the steps in the following Microsoft article and check if it helps.

    Change appear on the taskbar buttons:

    http://Windows.Microsoft.com/en-us/Windows7/change-how-buttons-appear-on-the-taskbar

    The taskbar (overview):

    For Windows 7: http://Windows.Microsoft.com/en-us/Windows7/the-taskbar-overview

    For Windows Vista: http://windows.microsoft.com/en-US/windows-vista/The-taskbar-overview

    For Windows Vista: http://windows.microsoft.com/en-US/windows-vista/Taskbar-recommended-links

    And see also: Suggestions for a question on help forums:

    http://support.Microsoft.com/kb/555375

    Hope the information is useful, if you are referring to the Internet Explorer toolbar, then just reply to us for additional help.

  • How to save the table column and row headings

    I have a table where I activated the column and row headings.  Once the table is loaded with data, I would like to save the contents of the table, including the column and row headings in a text file.  The crux of "value" property returns only the content of the table, not the row and column headers.  I could use "header line chains []" and '[] column header chains' property nodes as well, but I'm in the island there is an easier way.  Looks like adding the headers of lines would be difficult.  Any ideas?

    Thanks in advance.

    Here is a way. The construction with the empty constant is to provide to the left corner of the table where there is no data.

Maybe you are looking for

  • ADC signal formatting problem!

    Personal salvation OR. IAM having problems trying to measure tension in the port adc to a PIC 18F4550 through Labview. the fact is that iam like a beginner in programming G, and I don't know how to maintain the chain that iam get VISA read module and

  • Conclusion compressed on outlook express

    Received message on Outlook Express to compact files. Trace statements now unable to locate files containing the address book etc.

  • The computer video card can't read the themes

    My computer has a bad sector and Vista had to be put back. I used to have my picture as my screensaver and your display fadin in and out, pan and zoom, style, album etc. Now, they just flip with no transition. I get a meaasge reading:"this video card

  • SIM card and the mobile broadband card

    I have doubts on the WWAN card, I do not use the external for internet modem because I prefer internal modem please give solution on WWAN card, I use my L502x xps and my network 10W is Intel Centrino Advanced - N 6230 and there is a slot for SIM unde

  • updates KB3045999 and kb3046269 keep installed successfully

    Windows 7 Home premium sp 1, 64-bit version. After last Tuesday (14/03/2015), updates KB3045999 and KB3046269 keeps the installation successfully, but every day I ask myself to install again. Several others on the same day impossible installation - K