How to convert (multiple) output lines (multi-column)


HII


I have a weird request. But not sure how to get results out of it!


My query returns two rows to a query I asked.



Current result
10
20

Expected result

10 20

My problem here is that I wanted two values above to be stored in two variables in a single select statement.



If I use a cursor that my problem will be solved. But I'm not much interested in using a cursor for a simple select statement.



is there a possibility that I can convert the output of two lines to two columns?



I use Oracle Release 10.1.0.2.0



Windows Xp operating system.



People here will not appreciate the tags 'Urgent '. I know that :-(.



But some how I'm forced to use this tag "urgent." Sorry for that.



If no response, I will in another way can go to the slider :-(



Any help will be appreciated.



Thank you
Pavan

??? WITH the clause is just a quick way to produce one on the fly table with your sample data. I think you should do a lot of reading material. In any case, use:

select  dept,
        max(decode(rn,1,location,null)) location_1,
        max(decode(rn,2,location,null)) location_2
  from  (
         select  dept,
                 location,
                 row_number() over(partition by dept order by location) rn
           from  (
                  your-query
                 )
        )
  group by dept
/

SY.

Tags: Database

Similar Questions

  • error handle output line 45 / column 9 / errors/warnings - tag must be associated, missing: [< /li > < /li > < /li > < /li >]

    I get this error using DW cc 2015 "error manage output line 45 / column 9 / errors/warnings - tag must be associated, missing: [/li > < /li > < /li > < /li > <]" How can I fix?

    Add one or more closing tags.

    Without seeing the code, it is impossible to tell where exactly, but a list item must be closed...

    • point 1
    • point 2
    • point 3
    • point 4

  • How would add labels to lines and columns of a spreadsheet?

    I got some data of an oscilloscope, which has about 500 lines I want to the label at the time of measurement (1ms, 2ms, 3ms...) and about 10 columns I want to mark it with a corresponding wavelength (800 nm, 805nm, 810nm...). Any idea or links to examples would be appreciated.

    Gregory

    Before you write data in your spreadsheet file, write a line of column names.  Just make a table 1 d of strings with column names.  Write the 1 d array to the worksheet.  If you want labels on each line, you will need to convert your data into strings.  So, you will have a table 2D-string data.  Create a table 1 d of your line labels.  Insert in the table to insert your picture label in the data table, making sure to wire a 0 in the index of the column, not the index of the row.  This will put your labels in the first column.  Then write the 2D table in the spreadsheet file.

  • How to convert multiple photos stored as layers in a sequence in the timeline using the CC of the PS?

    I would like to be able to convert multiple photos of a subject in video high resolution using the timeline in PS CC.

    Here's how you can import a folder of images which become images in a video layer.
    Using Photoshop | Import video files and image sequences

  • How to convert multiple DNG size full of lossy DNG in Lightroom?

    Hello

    When I select several DNG in Lightroom and my mac, go to menu > library > convert photo to DNG and then choose Convert to DNG with the lossy mode, only the selected DNG is converted. How to convert more at the same time? I have a large library, and I want to convert ~ 100 GB of photos at a loss.

    Thanks in advance!

    How to convert more at the same time? I have a large library, and I want to convert ~ 100 GB of photos at a loss.

    Using Photos of the library/convert to DNG, if you're in something other than the display of the grid, one photo will be converted even if several are selected.  Its the same way that all orders (perhaps not all) work in library mode, you must be in mode grid for multiple photo stock.

  • I still have not found "help" to tell me how to remove all the lines and columns beyond those needed for my spreadsheet.

    I used several worksheets.  More allows me to specify the rows/columns and then delete them.  This is to remove all the lines/columns beyond those set up and formatted for my spreadsheet.   I tried many ways to remove all additional lines/columns, but without success.  I even took the time to scroll down/on to highlight all the unnecessary lines and columns, but they do not remove it.
    Any suggestions?  I used spreadsheets most allow me to specify the number of rows/columns for my worksheet

    You can ask your question in the office | Excel Forum because it is not really a problem of Windows XP performance and maintenance.

    Office | Excel

    http://answers.Microsoft.com/en-us/Office/Forum/Excel

    Also, providing specific information may help to get a faster response or better, such as the version of Office or Excel? version of Windows XP? Home, Pro, 32-bit or 64-bit.

    I hope this helps.

  • How to convert multiple lines in 1 row of columns across

    Hello

    My DB 10g

    My data as below,
    84A8E46E9366     20111008133638
    84A8E46E9366     20111112000531
    84A8E46E9366     20111212004432
    84A8E46E9366     20120127173533
    84A8E46E9366     20120226235444
    I've already tilt it by
    select 
    msid,
    rtrim (xmlagg (xmlelement (e, fee || '|')).extract ('//text()'), '|') fee
    from 
    aaa_bill
    where msid='84A8E46E9366'
    and fee is not null
    group by 
    msid;
    and get the result as below with only 2 column
    84A8E46E9366     20111008133638|20111112000531|20111212004432|20120226235444|20120127173533
    but I need the result to be on multiple columns.
    so I tried the following
    select msid,REGEXP_SUBSTR ( fee
               , '^[^|]*'
               )
    from 
    (
    select 
    msid,
    rtrim (xmlagg (xmlelement (e, fee || '|')).extract ('//text()'), '|') fee
    from 
    aaa_bill
    where msid='84A8E46E9366'
    and fee is not null
    group by 
    msid
    )
    ;
    but the result, only the first string

    84A8E46E9366 20111008133638


    is it possible to get Thos on several columns each string on column separated automatically because I have about 20000 msid separate

    Hello

    See the FAQ forum: {message identifier: = 9360005}

    In Oracle 10, you can do this:

    WITH     got_c_num     AS
    (
         SELECT     msid
         ,     fee
         ,     ROW_NUMBER () OVER ( PARTITION BY  msid
                                   ORDER BY          fee     -- or whatever
                           ) AS r_num
         FROM     aaa_bill
         WHERE     ...
    )
    SELECT       msid
    ,       MIN (CASE WHEN c_num = 1 THEN fee END)     AS col_1
    ,       MIN (CASE WHEN c_num = 2 THEN fee END)     AS col_2
    ,       MIN (CASE WHEN c_num = 3 THEN fee END)     AS col_3
    ...
    ,       MIN (CASE WHEN c_num = n THEN fee END)     AS col_n
    FROM       got_c_num
    GROUP BY  msid
    ORDER BY  msid     -- If wanted
    ;
    

    Note that you must specify the number of columns in the output. If you are unsure, do a high hypothesis. The query works always; unused columns will be NULL.

    Published by: Frank Kulash on 12 March 2012 14:45

  • How to convert multiple lines in a row in oracle?

    There is output

    status st_nm County
    AN OPEN 12
    A NARROW 13
    B OPEN 1
    B CLOSE 2

    EXPECTED RESULTS
    st_nm OPEN_count CLOSE_COUNT

    A 12 13
    1 2 B

    give the possibility of solutions?

    Published by: 886380 on September 30, 2011 05:53

    Published by: 886380 on September 30, 2011 05:54

    Published by: 886380 on September 30, 2011 05:56

    Hello

    This is called a Pivot .
    Here's a way to do it:

    SELECT       st_nm
    ,       MIN (CASE WHEN status = 'OPEN'  THEN cnt END)     AS open_count     -- COUNT by itself is not a good column name
    ,       MIN (CASE WHEN status = 'CLOSE' THEN cnt END)     AS close_count
    FROM       existed
    GROUP BY  st_nm;
    

    The best way depends on your exact requirtements and your version of Oracle. (The query above will work in Oracle 8.1 and higher).
    For more information, see the FAQ for the forum page:
    SQL and PL/SQL FAQ

  • How to convert multiple files in Illustrator CMYK?

    A major challenge for the professional Illustrator. I have several illustrator files in RGB and need to convert them to CMYK because I need to use for printing. Are nearly 200 files. If it's images, it would be easy, because it will create an action in Photoshop and apply the batch processing function. But how to do something in Illustrator?

    Perform the conversion on output in ID. There is no need to do it manually before hand. Check in the forum ID.

  • How to check multiple values with another column?

    Hi all

    create table xxc_abc (col1 , dept_id number number);

    create the table xxc_bbb (col2 number,sa_dept_id number);

    insert into xxc_abc values (1,10)

    insert into xxc_abc values (2,11)

    insert into xxc_abc values (3,12)

    insert into xxc_bbb values (20.10)

    insert into xxc_bbb values (20,11)

    insert into xxc_bbb values (20,12)

    SELCT

    xxc_abc a.,

    xxc_bbb b

    where a.dept_id = b.sa_dept_id

    Expected results

    a.Col1 b.col2

    ---------  --------

    1 20

    2 20

    3 20

    I need to get several values a.col1 with the same value of the b.col2 column

    a.Col1 b.col2

    ------- ------

    1 20

    2 20

    3 20

    Thank you

    Post edited by: Rajesh123 added Test cases in the main Thread

    Select the number you want to


    with

    xxc_abc as

    (select 1 col1, 10 dept_id in union double all the)

    Select 2,11 Union double all the

    Select double 3.12

    ),

    xxc_bbb as

    (select col2 20, 10 sa_dept_id union double all the)

    Select 20,11 Union double all the

    Select 20,12 double

    )

    Select col1, col2, cnt_all, cnt_not_null, cnt_unique

    from (select a.col1, b.col2,

    Count (*) on cnt_all (b.col2 partition).

    Count (a.Col1) on cnt_not_null (b.col2 partition),

    Count (distinct a.col1) on cnt_unique (b.col2 score)

    xxc_abc a.,

    xxc_bbb b

    where a.dept_id = b.sa_dept_id

    )

    where least (cnt_all, cnt_not_null, cnt_unique) > 1

    order by col1

    COL1 COL2 CNT_ALL CNT_NOT_NULL CNT_UNIQUE
    1 20 3 3 3
    2 20 3 3 3
    3 20 3 3 3

    Concerning

    Etbin

  • How to convert the output to Go

    The cmdlet Get-data store already returns the same values in the GB, see CapacityGB and FreespaceGB.

    But regardless of that, you can still do the conversion yourself.

    Something like this for example

    FreeSpace = $_. FreeSpaceMB / 1 KB

    And to get the rounded numbers, you can make

    FreeSpace = [math]: Round (($_.)) FreeSpaceMB / 1 KB), 0)

  • How to automate multiple output of a single input image file names?

    I have about 100 eps 4000 pixels wide to treat everyday CMYK images.  The site needs of several editions of the same image jpeg: 1000 pixels wide, 850 pixels wide and 80 pixels wide.

    Question:

    Can I load the single source and save three exits named differently through a single drop?

    I expect an automatism-> response of the lot, but I'm a programmer.  I haven't touched ExtendScript nor anything in CS scripted, but I can certainly read about it.  References to methods that would do a "save under" very similar to save Jpeg for the Web or I can download examples?  All links would be useful.

    You can find many examples in ps - scripts.com

    IE: http://www.ps-scripts.com/bb/viewtopic.php?t=3247

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

  • Is it possible particularly handy/quick to disable controls (multi-column listbox) when executing the output material associated?

    Please excuse me if the title of the post is not clear, I would try to explain what I need to do here.

    In the application, I am currently in train, UI use multi column listboxes in several places where a set value (one line) is selected, and based on the rowset / selected, relay/material are enabled to match a given configuration (which is then verified with your comments).  The problem is, I can easily rush into the user interface and make program stuttering and choke...

    I just put my finger down in one of the rows in the listbox control and drag my finger up and down the screen as a 5 year old child see a touch screen for the first time - he tries to each entry cache/buffer.  After I stop being 5 years old again I sit and listen to the click click of the relay for a bit.  One of these list boxes, I've already implemented enable and disable to pieces of code to implement the right before the digital output and solve the controls right after that feedback has been verified.  It was kind of a pain to do, so I wonder if there is an easier way to do it.

    Any idea or suggestion appreciated!

    Thank you

    -Pat

    PS - i As training until this weekend so I will probably not be quick to answer, but still thx for any info

    Use a "Mouse Up" event instead of an event of "change the value.

Maybe you are looking for