Need query to convert Single Row Multiple Columns To Multiple rows

Hi,
I have a table with single row like below
Column0 | Column1 | Column2 | Column3 | Column4|
Value0    | Value1    | Value2    | Value3    |  Value4  |
Am looking for a query to convert above table data to multiple rows having column name and its value in each row as shown below
Column0 | Value0
Column1 | Value1
Column2 | Value2
Column3 | Value3
Column4 | Value4
Thanks in advance.
Mohan

Hi ykMohan,
Dynamic UNPIVOT can be applied in this case as well.
CREATE TABLE dbo.T(ID INT,Column0 VARCHAR(99),Column1 VARCHAR(99),Column2 VARCHAR(99),Column3 VARCHAR(99),Column4 VARCHAR(99))
INSERT INTO T VALUES
(1,'Value0','Value1','Value2','Value3','Value4'),
(2,'Value0','Value1','Value2','Value3','Value4');
DECLARE @columns VARCHAR(MAX)
SELECT @columns=
STUFF(
SELECT ','+ COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME ='T' AND TABLE_SCHEMA='dbo' AND Column_name NOT IN('ID') FOR XML PATH('')
),1,1,'')
DECLARE @Sql NVARCHAR(MAX)
SET @Sql =
'SELECT ID, UPT.col,UPT.val FROM T
UNPIVOT
(val FOR col IN('+@columns+')) AS UPT'
EXEC sp_executeSQL @Sql
DROP TABLE T
If you have any feedback on our support, you can click
here.
Eric Zhang
TechNet Community Support

Similar Messages

  • Indexing multiple columns in multiple tables

    I have a multiple tables in which I want to search. I need to do text search that supports fuzzy logic for which I've currently set up a context index using the user_datastore. I also need to search columns such as numbers/dates/timestamps which from what I understand is not supported with the context search. I'm looking at setting up a second index of type ctxcat for this purpose - but I will need to index multiple columns in multiple tables. Is this possible?
    Can someone advise on the best way to create indexes and search when a table schema such as the following exists. I've tried to keep it simple by just giving a few example columns and tables.
    Order Table
    - Has columns related to the order details - order name (varchar2), description (varchar2), date order placed (timestamp), date order completed (date), order amount (number), customer Id
    Customer Table
    - Has columns related to the customer information - customer name, address, city, state, telephone etc (all varchar2 fields)
    Items Table
    - Has details about the items being ordered - item name (varchar2), item description (varchar2), cost (number) etc
    Order-Item Table
    - Table that maps an order to the items in that order - orderId, itemId, quantity
    Comments Table
    - Logs any comments with the customer - comment description (varchar2), call type (varchar2), comment date (timestamp)
    Currently with the Context index, I have it set up so I can search all text columns in all tables for a search term. This works fine.
    I now need to be able to do more advanced searches, where I can search for a specific text in all orders as well as orders created after a certain date or orders above a certain amount or orders with a item quantity purchase of more that 10. The text has to be searched across the all text columns in all tables. How can I achieve this with Oracle Text?

    There was a similar discussion with various ideas that may help you here:
    How can I make CONTAINS query work for a date range

  • Printing 1 Label in Row and Column Other Than Row 1, Column 1

    I want to print 1 label and want to print it on Avery label stock in a row and column other than row 1, column 1. I'm using Avery Labels 8163. I can select the row and column I want to print on in Word but can't figure out how to do it in *Address Book*. Anyone know how to do this?

    You can't do that in Addrress Book. But you can use pearLabelizer to do that. Be sure you download and install the appropriate Label Definition file and name it as such so you can select it from the pop-up list in the program's Preferences window.

  • Indexing multiple columns of multiple tables

    Hi,
    I'm trying to index multiple columns of multiple tables.
    As I have seen, the way to do this is using User_Datastore.
    have the tables to share a (foreign)key? My tables have only 2 or 3 similar columns(description, tagnr...)
    I want to get the different tagnr belonging to the same description etc.
    Can I do this?
    Has anyone a Samplecode indexing multiple tables?
    Any suggestion would be helpful.
    Arsineh

    A USER_DATASTORE works like this:
    create table A
    ( id number primary key,
    textA varchar2(100));
    create table B
    ( id number primary key,
    textB varchar2(100));
    procedure foo (rid in rowid, v_document in out varchar2)
    v_textA varchar2(2000);
    v_idA number;
    v_textB varchar2(2000);
    begin
    select id, textA
    into v_idA, v_textA
    from A
    where rowid = rid;
    select textB
    into v_textB
    from B
    where id = v_idA;
    v_document := textA | | ' ' | | textB;
    end;
    create preferences for USER_DATASTORE
    create index ...
    on table A ( text) ...
    you also can build on table B
    This depends where you want the
    trigger to be build to sync the
    documents.
    null

  • Setting different Tabel Cell SemanticColor for Multiple Columns of each row

    Hi,
    I have requirement of setting different colors to different columns for each row based on some condition in table data.
    The data to table is coming from model, hence table is mapped to model node and attributes.
    I have created Seperate Node CellColorNode with attribue CellClr1 and CellClr2 of type TextView Semantic Color.
    Set the calculated, read only attribute to True. Mapped table columns text view to the CellColorNode->CellClr1 and CellColorNode-->CellClr2 correspondingly.
    Now, my query is how do i set the colors to CellClr1 and CellClr2 attributes. As I need to set the color for multiple columns of each table row.
    Is it in method getColorCellCellClr generated? Any  Example Code?

    Its resolved by following below link
    http://scn.sap.com/thread/158286

  • Multiple columns with uneven rows

    Good Evening Everybody
    Could somebody advise me on the best solution to do the following.
    I have a csv file. The csv file is being read using "read from spreadsheet file" vi.
    The file contains multiple columns. The columns all have a different last row address. By this I mean that...say...the last row of column 1 is 5. Column 2 last row is 23, Column 3 last row is 12. etc. The file might look like the following...note...this is an example of a file only, and any implications can't be construed.
                Column1    Column2    Column3    Column4     Column5
    Row1        0               1                 2             3                 4
    Row2       12             23              13            34                 0
    Row3       11             44              23                               11
    Row4       34             55            
    Row5       21           
    Lets assume that the value(s) of interest are contained in columns 2,4 and 5. Therefore the values I want to extract would be 55, 34 and 11
    I can select the columns of interest fine, but am having difficulty working out how to find the last row for these columns
    Caveats:
    1. The number of columns changes
    2. Position of column in file changes address...never found in same address
    Does anybody know how I might be able to locate the last row in the column of my choosing.
    Thanks for any assistance.
    best regards
    Ray

    Hi Ray,
    load the csv as an array of strings. Empty cells will result in empty strings. So you can easily test each column for an empty item, which will mark the "End of Data"...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Stored procedure in  package return multiple columns from multiple tables

    Hi ,
    Can a single stored procedure return multiple column values from different tables.
    example:
    tabA: col2, tabB:col3,tabC:col4 etc.
    one more question:
    if a stored procedure like to return 10 columns for a particular record from a single table do i need to define a TYPE statement for each colum like
    TYPE col1 is TABLE of varchar
    TYPE col2 is TABLE of varchar
    here i want to return only one row, not many rows.
    thanks

    You can try one procedure with OUT or IN/OUT parameters that collect the values from one or more sql statements.
    CREATE OR REPLACE PROCEDURE P1
    (P_COD IN TABLE.COD%TYPE,
    P_DESC1 OUT TABLE1.DESC1%TYPE,
    P_DESC2 OUT TABLE2.DESC2%TYPE)
    IS
    BEGIN
    SELECT table1.DESC1, table2.DESC2
    INTO P_DESC1, P_DESC2
    FROM TABLE1, table2 WHERE
    table1.COD = P_COD and
    table1.cod = table2.cod ;
    END P1;
    JP

  • Index Multiple Column of Multiple Tables

    Hi All,
    I would like to know how to create a index which can search through all column in my database tables. Eg: I have 30
    tables and every tables have around 10 columns. I want to create a index which can search through the columns in
    these tables.
    I know that User_DataStore can helps in create multiple column search across multiple tables. But in my case the BLOB
    created will be very huge. Any work around? I mean is there any solutions like concatenated datastore?
    Thank You.
    Regards,
    LG Tan

    Hi,
    I figured out how to do this today. The first thing is that the type of index you need is a USER_DATASTORE.
    The idea behind this type of index is pretty straight forward but the documentation does a very good job of not drawing attention to just how powerful it is.
    The idea behind a USER_DATASTORE is that you can write your own stored procedure to extract the data that you want to index and return it to the indexer. Take an example where you have a master table which contains enough information to allow you to find associated data in other tables i.e. a shared key. The idea is that when you set up a USER_DATASTORE index, you specify the name of a stored procedure that the indexer will call for each row in the master table. The stored procedure has one input and one output parameter, rowid (in) and clob (out).
    When the index is created, the stored procedure you specify is, as I said above, called for each row in the master table. Your stored procedure uses this ROWID to extract the shared key (this can be anything you want) from the master table and uses this to build the necessary SELECT statement to retrieve the related data from the other tables. The rest of the stored procedure simply appends the data returned from your select statement to the return CLOB. The indexer then indexes the inforamation in this CLOB and discards the data.
    The index can of course only return hits against the master table. It's up to your application to extract shared key from the returned row(s), bind to the other tables and present the results.
    You will find a basic example of how to implement USER_DATASTORES in the Oracle Text Reference Guide (http://download.oracle.com/otndoc/oracle9i/901_doc/text.901/a90121.pdf). Feel free to email me if you want some example code.
    Dean

  • Continuing column from last row of column to first row of next column.

    Hi! I have been wrestling this bear for weeks now. I am scanning a lot of seals the same size, approximately 3" x 2". I only want my spreadsheet to scan 1 number in each cell and when it reached the bottom of Column A Row 8, I want the next # I scan to jump to Column B Row 1 and continue dow until it gets to the bottom of Column B Row 8, then I want it to jump to the next column, Column C and scan to the bottom row.
    Can I do this????? Help!

    I am working on an upcoming election and I have created a spreadsheet with 4 columns and 8 rows. I am scanning seals with barcodes on them. Each has its own unique barcode. I use a handheld scanner, like you would see someone at Wal-Mart scanning inventory or doing a price check. When I begin scanning these seals the first one I scan goes into cell A1 and then automatically moves to the next row down. Then I scan the next and it goes into A2, etc. BUT when I reach A8, and scan the next #, it moves into A9 but I want it to go to B1. This is a small election and I don't have as many to do this time and I am trying to figure out how to make it do this now so I have my template ready for the next big election. The seals are all attached like a continuous roll of mailing labels. I am only doing 28 seals this time for each location but I have over 40 locations. 1 page of 28 seals, all with individual barcoded seals for each. In a big election I might scan 80 - 90 seals per location and going all down one column would take several pages. (I use a large font so they can easily be read). Otherwise I have to stop at the bottom, A8, go to the keyboard and move the mouse to click in B1 and start scanning the next 8 #'s. So what I am trying to do is this ...... I have a roll of seals and I begin scanning each seal without having to use the keyboard and touchpad. After each barcode scan it automatically moves to the next cell down. When I reach A8 and scan the barcode I want it to automatically move to B1. I want my table to end at A8 as if there is no other cell below it. I actually have an Excel SS set up in Windows and it will do this on some I have created, but not others. I can do a Save As but it doesn't bring that feature over and I can't figure out how I got it set to do that in the first place.!??? Those crazy Windows machines! So I am trying to see if I can get my Numbers SS to do this. Maybe it is not an option in Numbers. Sorry for the long detail but if somebody knows how to do this I sure would appreciate that info. Thanks!!!

  • Multiple columns for the rows

    Hello everyone,
    Can anyone give me a logic in the below scenario.
    Table A
    Col1 Col2 Col3
    Peter 01-jan-2009 1000
    Peter 7-mar-2009 1000
    Peter 13-dec-2009 1000
    i need a sql which displays all the data in a single row in such a way that
    1) if col2 month is jan, then the column heading should be "January" and value should be Jan
    2) if col2 month is mar, then the column heading should be "Marchh" and value should be Mar
    3) if col2 month is dec, then the column heading should be "December" and value should be Dec
    Thank you in advance.

    This may help
    WITH DATA AS (
    SELECT 'Peter' NAME,to_char(to_date('01-jan-2009','dd-mon-yyyy'),'MON') MON, 1000 salary FROM dual UNION
    SELECT 'Peter' NAME,to_char(to_date('07-mar-2009','dd-mon-yyyy'),'MON') MON, 1000 salary FROM dual UNION
    SELECT 'Peter' NAME,to_char(to_date('13-dec-2009','dd-mon-yyyy'),'MON') MON, 1000 salary FROM dual
    SELECT NAME,max(decode(mon,'JAN',salary)) jan,
    max(decode(mon,'FEB',salary)) FEB,
    max(decode(mon,'MAR',salary)) MAR,
    max(decode(mon,'APR',salary)) APR,
    max(decode(mon,'MAY',salary)) MAY,
    max(decode(mon,'JUN',salary)) JUN,
    max(decode(mon,'JUL',salary)) JUL,
    max(decode(mon,'AUG',salary)) AUG,
    max(decode(mon,'SEP',salary)) SEP,
    max(decode(mon,'OCT',salary)) OCT,
    max(decode(mon,'NOV',salary)) NOV,
    max(decode(mon,'DEC',salary)) DEC
            FROM DATA
    GROUP BY NAME
    NAME     JAN     FEB     MAR     APR     MAY     JUN     JUL     AUG     SEP     OCT     NOV     DEC
    Peter      1000          1000                                             1000cheers!!!
    Bhushan
    Edited by: Buga on Nov 2, 2009 10:38 PM

  • Help needed in PL/SQL for updating the column for multiple records

    Hi,
    I am new to PL/SQL and need some help. What is the most effiecient way to update some field in a table as I may need to update thousands of records. I have a coulmn groupid can have multiple records tied to it. All the records attached to some groupid have a priority field also.
    How can I update the prorityfield value for all the groupids in a profiecient way. Here is a sample data
    GroupId     Priority
    1            1
    1            2
    1            3
    1            4
    1            5
    2            1
    2            2
    2            3
    3            1Here I have three groups 1, 2, 3. Now if any group contains only one record the priority remains same e.g. groupid=3 on top. If any group contains more than one record e.g. groupid=1 & 2 I want to re-arrange the priority fields e.g. If I want to update groupid=1 now if I change the priority of 2 to 5 (make it the last) I want to rearrange the remaing records priority i.e. if 2 becomes 5 as I have 5 rows for groupid=1 then 5 becomes 4, 4 becomes 3, 3 becomes 2 and 1 remains the same.
    Same wya if I want to make the priority 1 to 3 for groupid=2 then need 2 to become 1 and 3 to become 2 etc....
    Any help is appreciated.
    Thanks

    Hi,
    You don't need PL/SQL to do this (though you can put the following in PL/SQL if you want to):
    UPDATE     table_x
    SET     priority = CASE
                   WHEN  groupid     = 1
                   AND   priority = 2
                        THEN  5
                   WHEN  groupod     = 1
                   AND   priority     BETWEEN 3 AND 5
                        THEN  priority - 1
                   WHEN  groupid = 2
                   THEN
                        CASE
                             WHEN  prioity = 1
                             THEN  3
                             ELSE  priority - 1
                        END
                 END
    WHERE     groupId          IN (1, 2)
    AND     (     priority     BETWEEN 2 AND 5
         OR     groupid          = 2
         );There are lots of different techniques that can reduce your coidng: for example, the nested CASE statement used for groupid=2 above.
    You could do several smaller UPDATEs (for example, one just for groupid=1). Execution will be slower, but coding and testing will be faster.
    You could make the "magic numbers" 2 (for groupid=1) and 1 (for groupid=2) variables, even outside of PL/SQL.
    If you need more help, post the information that Satyaki requested.

  • Select Query where multiple column in multiple values (cant use in clause)

    I can use (in clause) with on column like this:
    Select code from table where code in(1,2,3)
    -------------------------------My case:-------------------------------------------------
    I’ve 4 columns PK of table as below 
    I need to :
    select
    where (code, month, year) in ((1,1,2013) and (2,1,2014) and (2,2,2015))
    i can't write it this way :
    select where code in (1,2) and month in (1,2) and year in (2013,2014,2015)
    case i'll get my rows but others included like (1,1,2015) , (1,1,2014),(2,1,2013) .. etc
    I’m terribly want to solve this problem
    Please help me
    Code (pk)
    Month (pk)
    Year (pk)
    emp_code(pk)
    1
    1
    2013
    101
    1
    1
    2013
    102
    2
    1
    2013
    101
    2
    1
    2013
    102
    1
    2
    2013
    101
    1
    2
    2013
    102
    2
    2
    2013
    101
    2
    2
    2013
    102
    1
    1
    2014
    101
    1
    1
    2014
    102
    2
    1
    2014
    101
    2
    1
    2014
    102
    1
    2
    2014
    101
    1
    2
    2014
    102
    2
    2
    2014
    101
    2
    2
    2014
    102
    1
    1
    2015
    101
    1
    1
    2015
    102
    2
    1
    2015
    101
    2
    1
    2015
    102
    1
    2
    2015
    101
    1
    2
    2015
    102
    2
    2
    2015
    101
    2
    2
    2015
    102
    thank you

    In T-SQL you have to use OR-ed predicates. 
    In full ANSI Standard SQL youcan write row comparisons  (a,b,c) = (1,2,3) etc! but not in T-SQL dialect. Ignoring that problem, what you have is a design flaw called attribute splitting; you have put one unit of measurement
    in two columns. 
     I like the MySQL convention of using double zeroes for months and years, That is 'yyyy-mm-00' for a month within a year and 'yyyy-00-00' for the whole year. The advantages are that it will sort with the
    ISO-8601 data format required by Standard SQL and it is language independent. The pattern for validation is '[12][0-9][0-9][0-9]-00-00' and '[12][0-9][0-9][0-9]-[01][0-9]-00'
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to Make FUNCTION to return multiple column and multiple row output

    Hi All,
    Kindly Share ur Idea;Thanks in Advance;
    i Have Table Demo.
    table DEMO:
    id name
    1 a10
    1 a11
    1 a12
    2 b10
    2 b11
    3 ccc
    and the function is like:
    create or replace function (p1 number) return varchar2 as
    vid number;
    vname varchar2(20);
    begin
    select id,name into vid,vname from demo where id=p1;
    return v1;
    end;
    this function returns output for id=3;
    BUT,
    i need output as (for input as 1)
    vid vname
    1 a10
    1 a11
    1 a12

    A function returns a single datatype.
    That datatype may be an atomic datatype (varchar2, number etc.) or it may be an object/record datatype, or even a collection datatype.
    Where are you going to use this function? In PL/SQL or SQL?
    If you are wanting to use it in SQL, then you would need a pipelined function e.g.
    SQL> CREATE OR REPLACE TYPE myemp AS OBJECT
      2  ( empno    number,
      3    ename    varchar2(10),
      4    job      varchar2(10),
      5    mgr      number,
      6    hiredate date,
      7    sal      number,
      8    comm     number,
      9    deptno   number
    10  )
    11  /
    Type created.
    SQL> CREATE OR REPLACE TYPE myrectable AS TABLE OF myemp
      2  /
    Type created.
    SQL> CREATE OR REPLACE FUNCTION pipedata(p_min_row number, p_max_row number) RETURN myrectable PIPELINED IS
      2    v_obj myemp := myemp(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
      3  BEGIN
      4    FOR e IN (select *
      5              from (
      6                    select e.*
      7                          ,rownum rn
      8                    from (select * from emp order by empno) e
      9                   )
    10              where rn between p_min_row and p_max_row)
    11    LOOP
    12      v_obj.empno    := e.empno;
    13      v_obj.ename    := e.ename;
    14      v_obj.job      := e.job;
    15      v_obj.mgr      := e.mgr;
    16      v_obj.hiredate := e.hiredate;
    17      v_obj.sal      := e.sal;
    18      v_obj.comm     := e.comm;
    19      v_obj.deptno   := e.deptno;
    20      PIPE ROW (v_obj);
    21    END LOOP;
    22    RETURN;
    23  END;
    24  /
    Function created.
    SQL> select * from table(pipedata(1,5));
         EMPNO ENAME      JOB               MGR HIREDATE                    SAL       COMM     DEPTNO
          7369 SMITH      CLERK            7902 17-DEC-1980 00:00:00        800                    20
          7499 ALLEN      SALESMAN         7698 20-FEB-1981 00:00:00       1600        300         30
          7521 WARD       SALESMAN         7698 22-FEB-1981 00:00:00       1250        500         30
          7566 JONES      MANAGER          7839 02-APR-1981 00:00:00       2975                    20
          7654 MARTIN     SALESMAN         7698 28-SEP-1981 00:00:00       1250       1400         30
    SQL> select * from table(pipedata(6,10));
         EMPNO ENAME      JOB               MGR HIREDATE                    SAL       COMM     DEPTNO
          7698 BLAKE      MANAGER          7839 01-MAY-1981 00:00:00       2850                    30
          7782 CLARK      MANAGER          7839 09-JUN-1981 00:00:00       2450                    10
          7788 SCOTT      ANALYST          7566 19-APR-1987 00:00:00       3000                    20
          7839 KING       PRESIDENT             17-NOV-1981 00:00:00       5000                    10
          7844 TURNER     SALESMAN         7698 08-SEP-1981 00:00:00       1500          0         30
    SQL> select * from table(pipedata(11,15));
         EMPNO ENAME      JOB               MGR HIREDATE                    SAL       COMM     DEPTNO
          7876 ADAMS      CLERK            7788 23-MAY-1987 00:00:00       1100                    20
          7900 JAMES      CLERK            7698 03-DEC-1981 00:00:00        950                    30
          7902 FORD       ANALYST          7566 03-DEC-1981 00:00:00       3000                    20
          7934 MILLER     CLERK            7782 23-JAN-1982 00:00:00       1300                    10
    SQL>If you are using it in PL/SQL then just populating a collection datatype and returning that will do. Though you should question why you want to pass large amounts of data around like that first.
    Explain your purpose and what you are intending to do and we can recommend the best way.
    {message:id=9360002}

  • Concatenate Multiple columns to one Row - Oracle 10.1

    Hi Friends,
    I have the item id in the item table and list of warehouses in another table.
    SDM_ITEM_TABLE
    ITM_ID ITM_DESC
    1 Baby Oil
    2 Shampoo
    SDM_OUTBOUND_LOG
    ITM_ID WHS_ID
    1 1
    1 2
    1 3
    1 4
    2 1
    2 2
    SDM_OUTBOUND_DESC
    WHS_ID WHS_SNAME
    1 NJ
    2 WN
    3 CA
    4 CN
    Expected Result
    ITM_ID WHS_SNAME
    1 NJ WN CA CN
    2 NJ WN
    I am using the below query to join the above 3 tables , but i am unable to concatenate the warehouse short names as displayed above.
    select t.itm_id,(SELECT H.WHS_SNAME FROM SDM_OUTBOUND_DESC H WHERE H.WHS_ID = t.WHS_ID) WHS_SNAME
    from SDM_OUTBOUND_LOG t, SDM_ITEM_TABLE i
    where t.itm_id = i.itm_id
    Please let me know how to proceed further in modifying the query to concatenate the warehouse names.
    Thanks

    Centinul gave you the links to many examples.
    You should try them all and find out how they work and let us know what parts are not clear.
    Not sure why you are joining all three tables here, it looks like the desired resultset can be selected using
    sdm_outbound_log and sdm_outbound_desc only?
    One way of concatenating column values, is to use SYS_CONNECT_BY_PATH (but there are many more).
    The query below reads from 'inside-out':
    SQL> create table sdm_outbound_log as
      2  select 1 itm_id, 1 whs_id from dual union
      3  select 1, 2 from dual union
      4  select 1, 3 from dual union
      5  select 1, 4 from dual union
      6  select 2, 1 from dual union
      7  select 2, 2 from dual;
    Table created.
    SQL> create table sdm_outbound_desc as
      2  select 1 whs_id, 'NJ' whs_sname from dual union
      3  select 2, 'WN' from dual union
      4  select 3, 'CA' from dual union
      5  select 4, 'CN' from dual;
    Table created.
    SQL> select itm_id
      2  ,      ltrim(replace( sys_connect_by_path(whs_sname, ',') 
      3                      , ',', chr(32)
      4                      )
      5              ) whs_sname
      6  from ( select l.itm_id
      7         ,      d.whs_sname
      8         ,      row_number() over (partition by l.itm_id order by l.itm_id) rn
      9         from   sdm_outbound_log l
    10         ,      sdm_outbound_desc d
    11         where  d.whs_id = l.whs_id
    12       )
    13  where connect_by_isleaf=1    
    14  start with rn=1
    15  connect by rn=prior rn+1    
    16         and itm_id=prior itm_id;
        ITM_ID WHS_SNAME
             1 NJ WN CA CN
             2 NJ WN
    2 rows selected.So, in the innermost query we start by using row_number() to obtain a rownumber within each occurence of itm_id,
    and then we connect by that rownumber and itm_id in the outermost query.
    Since it looks like you want your values delimited by a space, I added a replace and a ltrim.

  • Where is the "reference tab's pop-up menu" in this instruction, "To hide a single row or column, choose Hide Row or Hide Column from the row or column reference tab's pop-up menu."

    Where is ref tab's pop-up menu?

    I made this screenshot to show convert to header row which is done from the same pop-up menu. Hover your cursor between the row number & the first cell until you see the triangle then click the triangle.

Maybe you are looking for