Transpose rows to columns

Hello

I would like to translate some lines to columns that belong to one id. The order of the columns converted should be based on the date of descending treatment.

Examples of data include:

create table (test)
Identification number,
date of process_date,
cust_name varchar2 (20).
curr_add_1 varchar2 (20).
old_add_1 varchar2 (20).
curr_add_2 varchar2 (20).
old_add_2 varchar2 (20).
curr_add_3 varchar2 (20).
old_add_3 varchar2 (20))

Insert test values (001, January 1, 2000 "," Ltd GYB', 'Hugh Farm', 'Connell House', 'Regent Street', 'Downington', 'Hazlemere', 'Herts');
Insert test values (001, March 28, 2000 "," Ltd GYB ', 'Hugh Farm', ' 14 Connell House', 'Regent Street', 'Downington', 'Hazlemere', ' Herts);
Insert test values (002, June 23, 2012 ","RSG Ltd"," unit 8', 'Hurst House', 'Hind Road', 'Cumbria', 'Merrow', "");
Insert test values (002, 28-SEP-2013 ","RSG Ltd"," unit 14', 'Hurst House', 'Hind Road', 'Cumbria', 'Merrow', "");
Insert test values (002, 12 January 2014 "," RSG Ltd","unit 14', 'Hurst House', 'Hind Road', 'Cumbria', 'Merrow', 'Herts');

Expected results:


Columns:

ID - 001

CURR_ADD_1_1 = "Hugh Farm.

OLD_ADD_1_1 = 'Connell House. "

CURR_ADD_2_1 = 'Regent Street.

OLD_ADD_2_1 = "Downington.

CURR_ADD_3_1 = "Hazlemere".

OLD_ADD_3_1 = "Herts".

CURR_ADD_1_2 = "Hugh Farm.

OLD_ADD_1_2 = ' 14 Connell House. "

CURR_ADD_2_2 = 'Regent Street.

OLD_ADD_2_2 = "Downington.

CURR_ADD_3_2 = "Hazlemere".

OLD_ADD_3_2 = "Herts".

ID - 002

CURR_ADD_1_1

OLD_ADD_1_1

CURR_ADD_2_1

OLD_ADD_2_1

CURR_ADD_3_1

OLD_ADD_3_1

CURR_ADD_1_2

OLD_ADD_1_2

CURR_ADD_2_2

OLD_ADD_2_2

CURR_ADD_3_2

OLD_ADD_3_2

CURR_ADD_1_3

OLD_ADD_1_3

CURR_ADD_2_3

OLD_ADD_2_3

CURR_ADD_3_3

OLD_ADD_3_3

Post edited by: sliderrules

Is this something that you want?

where d

(select id, row_number () over (partition by order of the identification of process_date) rn, curr_add_1,)

old_add_1,

curr_add_2,

old_add_2,

curr_add_3,

old_add_3

test)

--

Select *.

d

Pivot (min (curr_add_1) as a1, min (old_add_1) as oa1, min (curr_add_2) as a2, min (old_add_2) as oa2, min (curr_add_3) as a3, min (old_add_3) as oa3 (RN) in (1,2,3));

Tags: Database

Similar Questions

  • Transposition of the SQL rows to columns

    Hi all -

    I have a query that returns the following result set:

    amount of the year amt_type

    2001 1000 holiday
    1000 medical 2001
    College of 2001 15000
    2002 800 vacation
    1000 medical 2002
    2002 10000 College
    2003 400 vacation
    2000 medical 2003
    College of 2003 80000.

    I'm doing the years 2001, 2002 and 2003 in columns and trying
    reach the bottom of output

    AMT type 2001 2002 2003
    1000 800 400 vacation
    Medical 1000 1000 2000
    15000 10000 8000 College

    I am able to achieve perfectly on the client side. Right now I'm trying to
    do the same with the help of SQL. I use

    DECODE to achieve but my result set looks like in below

    AMT type 2001 2002 2003
    Holiday 1000
    Holiday 800
    Holiday 400
    1000 medical
    1000 medical
    medical 2000
    College 15000
    College 10000
    College 8000


    I try this on oracle. I'm new to this concept. can anyone who has worked in
    similar situation help me. In addition, the years may change according to the drop-down list
    selection on the page of the client. Can I transpose the rows of columns in dynamic SQL
    values

    Thank you

    Something like that

    select amt_type,
    sum(decode(year, 2001,amount,0)) as 2001,
    sum(decode(year, 2002,amount,0)) as 2002,
    sum(decode(year, 2003,amount,0)) as 2003
    from table_name
    group by amt_type
    

    However you can not change number of columns dynamically.

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

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

  • Obtaining of row and column of a table element

    Hello

    I have a table of 24 rows and column 24 giving me a total of 576 items. How can I get the row and column of a particular element in a table in LabView. For example if I write to item 127 How can I get the column and line item 127 is located.

    Kind regards

    Bastien

    Hi Marion,.

    Maybe just need to find the right "address" element in your 2D table?

    Use something like this:

    Maybe you have to out of line & column according to your numbering scheme...

  • Write multiple rows and columns of the worksheet

    Is it possible to write several rows and columns of the spreadsheet, with the ability to add data to the file and create a new file if it does not exist?
    I tried to write to table vi, but I couldn't make it work.
    It won't let me write several lines in the same column.
    Can someone please give me an example?
    Thanks in advance.

    If you want to use the tab character (\t) as the delimiter, then check the txt file.  Then Excel will open as you wish.

    If you want to keep the csv extension, then use comma (,) as a separator.

  • config file error could not open the file line column 0 0 onfig file error cannot open file row 0 column 0 - whenever I try to open my hp game console

    original title: config file error could not open the file column line 0 0

    onfig file error cannot open file row 0 column 0 - whenever I try to open my hp game console... I get this error message...

    Hello

    Was the HP works well before game console? If Yes, then do you remember any hardware/software changes, after which the problem started?

    Method 1: I would say you put the computer to boot and then check if the problem is caused by any third-party application.

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

    Note: After troubleshooting, be sure to set the computer to start as usual as mentioned in step 7 in the above article.

    Method 2: I would say as you uninstall and reinstall the HP game console and check to see if it helps:

    Uninstall or change a program

    http://Windows.Microsoft.com/en-us/Windows-Vista/uninstall-or-change-a-program

    You can also try posting your question in the HP Support forums.

    HP Support Forums - operating systems and software

    http://h30434.www3.HP.com/T5/desktop-operating-systems-and/BD-p/OSandSW

  • 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 to copy/paste in rows and columns

    Let's say I have an object in PS (gummy bear for example) and I want to duplicate in rows and columns. Is there a way to do it automatically?

    1. open your file of gummy bear and resize the image to a smaller, if necessary.

    2 file > set the model. Name it and ok.

    3. open a new file, 8 x 10, for example

    4 edit > fill > model... and in the Custom model drop-down list, it will be the last of them. Choose it.

    5. click on OK

    Fact.

    If your want a space between gummy bear, add space in step 1

    Good luck

  • Insert only one cell in a table (not an extra set of the row or column)?

    I have problems by performing an easy Assembly. I need to insert a a 'CELL', but I am only considered the possibility to insert a set 'ROW' or 'COLUMN '. I would just insert a cell and the rest of the content below it moves accordingly. Help, please!

    There is no way to put it while you just insert a cell and everything moves along after that cell?

    Simple answer is 'no '. I'm sorry.

    InDesign tables are not good for juggling data. If you have a project that requires single-cell-integration on a regular basis, I suggest to make your table outside InDesign in an application with tools more easy table-cell-juggling (Excel comes to mind here) and then perfecting you use table and cell styles make it easy to update. Of course, it will always be a concern, but the hassle can be minimized.

  • Sortable rows and columns

    Is it possible to drag and drop the rows and columns of a multicolumn script to rearrange them. If this isn't the case, it would be appropriate.

    Please write to us.

    We do not expect to support mobile in an AV Scripts columns because they are only 2 columns fixed in script format.

    If you create a script to multiple columns and click on a column heading, you will end up by selecting the contents of that column. Press CTRL-X to cut this column, then press CTRLV to paste the column somewhere before an existing column.

    This should solve your problem.

    -Anubhav

    Anubhav Rohatgi

    Senior product manager

  • Max rows and columns

    What can be the maximum number of rows and columns, you can have in a table in an oracle database?

    See the limits of logical database in http://download.oracle.com/docs/cd/E11882_01/server.112/e17110/limits003.htm#i288032.

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

  • dynamic query, row to column

    Hello.
    There is a way to select a row as column for any table?
    I mean a script that have the name table and the status as input parameters and prints column_name | the value of the column;
    I tried to do, but having a few problems.
    for example to get table
    create table my_table (column1 number, column2 number, column3 number);
    insert into my_table values (1,2,3);
    It should be something like:
    declare
    lv_table_name varchar2(40):='MY_TABLE'; /*these are input paremeters*/
    lv_condition varchar2(300):='column1=1;/*these are input paremeters*/
    begin
    /*body*/
    end;
    and the output should be like (can use dbms_output)
    column1    1
    column2    2
    column3    3    
    Script should work for any table.
    Anyone solves similar to that task?

    http://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:1035431863958

    Research of print_table of the procedure on this page.

Maybe you are looking for

  • How 2 search within a PDF document using the PDF reader internal Firefox

    Could not find a way to search for text in a PDF document, when it is displayed by the PDF reader integrated into Firefox. If there is a way, how do you? If there isn't a way, it seems an obvious improvement.

  • Different questions on the new Satellite C855-2GX

    After buying Toshiba Satellite C855-2GX is really not worth everything $ pass on it that's the problem that I still meet the pc's NEW!For Specifcation: HARD drive of 500GB, 8 GB RAM Intel I5-Mouse Lag during the Anti-Virus Scan or install a heavy or

  • Pavilion G6-1321SX: I lost my product key Windows 7:(comment je peux le trouver?)

    I installed a new Windows 7 because I had problems with the previous, and I thought that the Windows product key is here somewhere, but I couldn't find it anywhere! not at the back of the laptop, not in the textbooks, nothingIs there a way to know wh

  • Lenovo USB G470 does not!

    Hello Just bought Lenovo G470 USB do not work properly, Deskjet printer continues to disappear and when I iPhone plugin to load - nothing happens, quite simply, it does not detect it. The drivers installed and the Device Manager wrote: works correctl

  • Need help with the use of beam between two subVis

    Hi all I have two inside a big Vi subVis that need to be connected one to the other. It's a complicated thing, I already have many sons in the wholesale Vi, which will become a mess if I connect these two subVis line-by-line (there are nearly 16 line