How to convert columns to rows

Hello

I have a table with 3 columns. I want to retrieve the columns in lines.

My requirement is that I asking only 1 row at any time.

with t as

(select ' 1 ', ' 2' col1 col2, col3 double null)

Select col1, col2, col3 from t;

The query above returns

1 2 NULL

I want to a query that returns

1

2

Basically, if the column value is null, I don't want a line for this.

1 2 3

would come as

1

2

3

Could you please help me find it.

with t as
(select '1' col1, '2' col2, null col3 from dual)
select * from t
unpivot(val for col in(col1, col2, col3));

That you will get only the non-null values.

If you want NULL values, thus:

with t as
(select '1' col1, '2' col2, null col3 from dual)
select * from t
unpivot include nulls (val for col in(col1, col2, col3));

Tags: Database

Similar Questions

  • 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.

  • Tabular: how dynamically toggle columns and rows

    Hello

    I am very new to ApEx sorry if this has been addressed before, but I can't find a solution in forums or with Google, so here I am.

    I have an table based on a view, with two elements as the primary key and instead - of trigger for update (only the updates made, not of insertions/deletions) and the form works fine (I can update and refresh, etc.) The form was created with the wizard, not manually.

    My problem is, I need to turn off (disable - not hide) of columns in the report to prevent changes according to the value of one of its own columns - for example, a value of + 'q' + in the column period is going to turn some columns, while value of + 'h' + will toggle other columns. (The 'q' / 'h' value is the same for all the lines in the form.)

    Similarly, I also need to toggle all lines according to the value of the column one another .

    To sum up, displaying the form of tables and according to the value of a column, I need to turn some of the columns. Thenfor each line that I sail and, according to the value of another of the column, I need to enable/disable one or more items on this line.

    Any detailed help on how to proceed would be greatly appreciated (and if you need more information please ask.)

    It was very easily in forms with the triggers when-new-record and the elements of parameters as enabled. I am really so confused as to how to do this with ApEx - not to mention that I am helpless with JavaScript... Given that the page works well with the wizard-generated form, I want to keep it this way, but I'm ready to learn new tricks if the solution is building manually (as explained here: http://www.oracle.com/technology/products/database/application_express/howtos/tabular_form.html) or do it with a dynamic query (as explained here: http://www.oracle.com/technology/products/database/application_express/howtos/dynamic_report.html) although I'm not sure to understand things , explained here (and if she needs clean MRU treat...?)

    Thanks in advance,

    Ludovic

    You are the very welcome. I had a lot of help at the beginning of this forum so I try my best to give back. :)

    Good luck for the demo!

  • How to convert the column online

    Hello

    Do is samble of my data, I need to convert columns into rows

    create table uload_table (id1 number, tidset varchar2(200));
    
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (1,1);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (1,2);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (1,3);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (1,4);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (1,5);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (1,7);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (1,8);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (1,10);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (2,2);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (2,3);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (2,4);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (2,5);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (2,8);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (2,9);
    Insert into UNLOAD_TABLE (ID1,TIDSET) values (2,10);
    select * FROM UNLOAD_TABLE ;
    ID1      TIDSET
    ----- ----------   
    1     1
    1     2
    1     3
    1     4
    1     5
    1     7
    1     8
    1     10
    2     2
    2     3
    2     4
    2     5
    2     8
    2     9
    2     10
    I need the result to be as below.
    ID1      TIDSET
    ----- ----------   
    1     ;1;2;3;4;5;7;8;10
    2     ;2;3;4;5;8;9;10
    any help please,.

    http://download.Oracle.com/docs/CD/E11882_01/server.112/e26088/functions089.htm#SQLRF30030

    Concerning

    Etbin

  • I tried to download a pdf and convert them into excel, but the data in excellent is always to the image format.  How can I get the pdf data into the columns and rows?

    I tried to download a pdf and convert them into excel, but the data in excellent is always to the image format.  How can I get the pdf data into the columns and rows so that I can do the calculations?

    If you start the https://forums.adobe.com/welcome Forums Index

    You will be able to select a forum for the specific Adobe products you use

    Click on the symbol "arrow down" on the right (where it is said to see all our products and Services) to open the drop-down list and scroll

  • 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.

  • How to convert varchar to DateTime?

    Hi all

    I have a field - "final payment".

    Data - type Varchar.

    Last completion date must be in the date format. So I want to convert Varchar to Date.

    How can I convert? Can someone please help me solve this problem.

    Hi Nicolas,.

    Gayathri Venugopal wrote:

    I have a table - order and I have a field " Latest_Completion_Date " which is in the format Varchar - ' 20150804'.

    select Latest_Completion_Date from order 
    output- 20150804
    

    I want to convert Latest_Completion_Date - '20150804' in Date format - 15-SEP-07 ".

    How to convert it?

    The column ORDER. LATEST_COMPLETION_DATE with the VARCHAR2 data type?

    How are "Last date" element filling in the form?

    You can use to_date and to_char in combination to get the required format:

    select to_char(to_date(latest_completion_date,'YYYYMMDD'),'DD-MON-RR') latest_completion_date
      from order
    

    Kind regards

    Kiran

  • How to convert datetime in a JSF page or within the object entity of seconds since 1970

    Please HELP I have a column of type bigdecimal seconds since 1970 representing datetime.

    for example

    DateTimeCol

    1333382669.06

    expected output for the datetime type is 2012-04-02 16:04:29

    I build JSF form that display the column DateTimeCol. DateTimeCol type and Date format

    YYYY-MM-DD hh: mm: but the output of the column DateTimeCol is 9616-11-09 03:09:06 and it won't.

    I do not know how to convert (1333382669.06 seconds since 1970) in datetime (2012-04-02 16:04:29)

    I'd appreciate your help.

    Your problem is that the date data type coming milliseconds and not in seconds. You should be abel to do the math and use a

    java.util.Date(your_sec*1000).tostring ();

    Google for a timestamp converter (e.g. Epoch Converter - Unix Timestamp converter) and enter your number

    Entry 1333382669.06 * 10 = 1333382669060 lets you get: (here I use only * 10 that you already have 1/100th of a second!)

    Assuming that this timestamp is in milliseconds:

    GMT: Sunday, March 24, 1974 06:24:26 GMT

    Timo

  • How to convert Date months in the database that points to the EBS, DWH not.

    Hi friends,

    We intend to create reports in OBIEE and the Source is EBS. This means that we do not want depends on Datawarehouse and Informatica and OBIApps. Simply create us some reports and that they refer to the EBS database.

    End of test, we took an HR report and it contains under columns:

    Months (Sun)
    Revenue by Division (Fact)
    Average cost per numbers of workforce (Fact)

    In my little survey, we found that the income column is of EBS: GL_BALANCES. And we have configured the base of W_Day_D table in DAC has no column months in EBS (not sure).

    Come to my problem, how can I call the month column in my data base stressed EBS. How to convert the Date months in my database.

    I can deceive me, but someone please look into this... How can I create columns for this exact report of OBI in EBS database instead of DwH.

    Thanks in advance...

    Raghu Jen7782

    Just confused here.

    Hang on, if I get it, you want to create report based on columns of EBS directly then using rt BI applications?

    There is then no question of using the W_DAY_D table then.

    Follow

    As long as you have Date column, you can use DB functions to convert them into months (just use the string SUBSTR to extract the month and the year).
    Create your own query instead of using the tables of BI APPS and try to bring a hybrid product.

    Sorry I'm wrong in the understanding of your needs, if I had properly then do the steps above.

    Mark correct or useful if this can help,

    Kind regards
    Rayan Vieira

  • OpenScript/Bank of data/how to convert string to int

    Hello

    As far as I know, the values read from the database is a type of Sting. Now, I want to convert a character number stored in the database of type int.
    For example, in "Test.csv" I stored the '9' in the column 'Number' character, then I use the following code to read the character and convert an int in one:
    getDatabank("Test").getNextDatabankRecord ();
    String Testnumber = "{{db." Test.Numberr}} '; Info (Testnumber);
    int number = Integer.parseInt (Testnumber);

    However, it seems this does not work, because he says "basic unexpected failure caused by: NumberFormatException occurred." For the input string: «{{db.» Test.Numberr}}.
    I think that this error can be caused by the conversion of character '9' int 9.
    Can someone tell me how to convert a character to be read from database in an int?

    Thank you very much!

    Kind regards
    Angyoung

    Hello

    You can use the same approach. Use eval()

    getDatabank("Test").getNextDatabankRecord();
    String Testnumber =eval("{{db.Test.Numberr}}") ;
    info(Testnumber);
    int number = Integer.parseInt(Testnumber);
    

    Kind regards
    Dembélé M

  • How to convert number in the Date format

    Hi Experts,

    I have a date column says. date key order number (ex: 20110202). How to convert this number in format DD/MM/YYYY.

    Thanks in advance
    V

    Vincent Krishna wrote:
    Hi Experts,

    I have a date column says. date key order number (ex: 20110202). How to convert this number in format DD/MM/YYYY.

    Thanks in advance
    V

    SQL> select to_char(to_date('20110202','YYYYMMDD'),'DD/MM/YYYY') from dual;
    
    TO_CHAR(TO
    ----------
    02/02/2011
    
  • How NOT to restrict no rows from two tables

    I have two identical paintings invoice and payment. The only difference is Invoice_id Payment_id, Invoice_Amt and Payment_Amt columns displaying the amounts and different IDS. Bank_ids, names, account_types are the same. Table Invoice has 3 rows and payment 2. Just, which means that there are 3 generated invoices, but the Bank has received 2 payments. I want to show Invoice_Amt and Payment_Amt using the sql query. But its gives me total 6 rows. Whereas, I want 3 of the invoice and 2 rows of table of payment to show by-side.

    CREATE TABLE Bill
    (invoice_id NUMBER
    bank_id NUMBER,
    bank_name VARCHAR2 (256),
    invoice_amount NUMBER);
    /
    -Invoice table has 3 lines showing 3 invoice AMT

    Payment of CREATE TABLE
    (payment_id NUMBER
    bank_id NUMBER,
    bank_name VARCHAR2 (256),
    Payment_amount NUMBER);
    /
    -Payment table has 2 lines showing 2 payments

    After executing this statement sql below, I get 6 rows:
    Select inv.invoice_amount, pymt.payment_amount in the invoice inv, dated payment where inv.bank_id = pymt.bank_id;
    How can I show 3 rows for the invoice and 2 payment... ?
    Thank you.
    select  inv.invoice_amount,
            pymt.payment_amount
      from  (
             select  invoice_amount,
                     bank_id,
                     row_number() over(partition by bank_id order by invoice_id) rn
               from  invoice
            ) inv FULL OUTER JOIN
            (
             select  payment_amount,
                     bank_id,
                     row_number() over(partition by bank_id order by payment_id) rn
               from  payment
            ) pymt
            ON (inv.bank_id = pymt.bank_id and inv.rn = pymt.rn)
    /
    

    SY.

  • Remove the separator of columns and rows in spark DataGrid

    Capture.PNG

    Hello

    try searching a bit on the web with no success - how can I remove / handful of visibility of the separators of columns and rows in the DataGrid to spark flex 4.5

    See photo with separators:

    Two ways:

    (1) write a simple custom following appearance (the empty rectangles will cause the separators to disappear):

    
    
    
        
    
            
                
            
    
            
                
            
    
        
    
    
    

    (2) make a copy of the default Datagridskin and remove parts of skin 'columnSeparator' and 'rowSeparator.

    -Kevin

  • How to handle columns THAT?

    Hi gurus,

    I do for the target load source. Have gone through the forums for a solution to my problem, I wasn't convinced on the answer found.

    the problem I have is - " I have 4 columns - update_user, insert_date and insert_user, update_date." I have to complete everything by the loading. "

    1. I traced the insert_date and the insert_user, sysdate and user interface directly, but with each repetition of the interface, ODI mark the line as update even if it is not an update. After the exam, I found that in the I$ _ table created during the race, it inserts sysdate and user in the fields and compares. Since the sysdate will not match, it will mark the line update. so, I tried loading them via a procedure and not directly.

    2. when I try to load the columns through a procedure, all columns are updated. but I need to only load the date and user columns in rows that are inserted/updated. so, this isn't the right approach.

    I will carry out a package to load I need to maintain a journal etl load table also.

    * the solution, I found was to duplicate and edit the additional SQL IKM updated * to do this. But I feel somehow, there is an easy way to do this.

    * Please help me with this. I really appreciate your times

    * Thanks in advance

    Can you please tell me what the IKM you use? Because if mapped to the target, then the ODI doesn't consider these columns in equation I $, then cannot be the reason for the Insert or Update.

    About the Insert and update, when you click the column, find you real estate to insert / update. Select insert only for Insert and check the update only for the update.
    Also it does not solve my problem of update_date and update_user. How the IKM fails to satisfy your request.

Maybe you are looking for

  • Why I'm not able to upgrade my 7.1.2 ios to ios 9.2.3

    I have iPhone 4S with ios7.1.2 I tried a lot of things to download ios 9.2.3 but isn't possible, why?

  • Satellite A200: Cannot install XP - HDD not visible

    Hello!! I have a Toshiba Satellite A200 and im not happy with vista!I have a version of windows xp to my my old laptop, but I can't install it, at the beginning of the instalation xp dosent recognize my drive sata hardI know that I nedded a floopy wi

  • WIRELESS / NETWORK CONTROLLER

    My IdeaPad Y510 suddenly shows the dreaded BSOD yesterday and after frantic efforts to solve this problem, I had to reinstall XP Prof SP2 [slipstreamed or other normal XPs didn't work]. All my drivers seem to work fine except for the Wireless which i

  • failure to activate windows Genuine xp home

    I have windows xp home key but I lost my disc. I used another drive on xp home to install and put my key while activating. I selected activate via the internet and had option your windows message has been activated. Now when I restart my PC it asks o

  • Vista crashed after installing MS office 2010 beta version

    Hello I have Windows Vista Home premium on my laptop with MS office 2007. Yesterday, I installed the version of MS office 2010 beta (with option to keep 2007 MS office). Afterwards, my PC crashed and I can't start. Each time, he attempts to perform t