Conversion of lines in columns in Oracle 9i

Hello

I use Oracle 9i.

Examples of data
row2col:

   
WITH t AS
(SELECT 'A' a,'B' b,'C' c, 'D' d  FROM dual)
SELECT *
FROM t

col2row:

WITH t AS
(SELECT 'A' col2row FROM dual UNION ALL
 SELECT 'B'  FROM dual UNION ALL
 SELECT 'C'  FROM dual UNION ALL
 SELECT 'D'  FROM dual)
SELECT *
FROM t;
I was able to convert the columns in lines to aid in SQL.
WITH t AS
(SELECT 'A' col2row FROM dual UNION ALL
 SELECT 'B'  FROM dual UNION ALL
 SELECT 'C'  FROM dual UNION ALL
 SELECT 'D'  FROM dual)
SELECT rtrim (xmlagg (xmlelement(e,col2row||',')).extract ('//text()'), ',')
FROM t ;
Please let me know how to convert rows to columns.



Thank you.

Published by: Suri on July 5, 2012 20:44
-Edition sample data

Still not sure if this is what you want, but you can go:

Connected.
SQL> with t as (
  2  select 'a' a,'b' b,'c' c, 'd' d  from dual
  3  )
  4  --
  5  -- actual query:
  6  --
  7  select decode(level, 1, a
  8                     , 2, b
  9                     , 3, c
 10                     , 4, d )
 11  from   t
 12  connect by level<=4;

D
-
a
b
c
d

4 rows selected.

Tags: Database

Similar Questions

  • Conversion of lines in columns

    Hi, I have a query that delivers a power of several lines (IE. no of days in a month).  How can I change my query so that instead of getting 31 lines for January, I'm going to a single line with 31 columns or values?  Thank you.

    Hello

    Maybe something like:

    SELECT TO_CHAR (TRUNC (inptdate, 'MONTH'), ' MM/YYYY') IN the month

    pltcode

    SUM (CASE WHEN EXTRACT (DAY FROM inptdate) = 1 THEN pltactlgen END) AS day_1

    SUM (CASE WHEN EXTRACT (DAY FROM inptdate) = 2 THEN pltactlgen END) AS day_2

    -- ...

    , SUM (CASE WHEN EXTRACT (DAY FROM inptdate) = 30 THEN pltactlgen END) AS day_30

    SUM (CASE WHEN EXTRACT (DAY FROM inptdate) = 31 THEN pltactlgen END) AS day_31

    OF pmc_actlgen

    WHERE inptdate > = TO_DATE (November 1, 2013 ", ' MM/DD/YYYY')

    AND inptdate<  to_date="" ('01/01/2014',="">

    GROUP OF TRUNC (inptdate, 'MONTH')

    pltcode

    ORDER BY TRUNC (inptdate, 'MONTH')

    pltcode

    ;

    If you would care to post CREATE TABLE and INSERT statements for your sample data and accurate results, you want from these data, then I could test this.  To keep things simple, just post data and the results for the 1st, 2nd, 30 and 31 of each month.  In your production code, you'll need to hardcode a column for each day of the month, but if you know how it for 4 days, adding the other will be negligible.  If your actual data have more than a month, or more than 1 value distinct from pltcode, then make sure that your sample data and results are, too.

    SELECT... PIVOT works in the database Oracle 11.1 and higher versions.  The above query will work in versions 8.1 and upward.

  • How to make the lines dynimac columns in Oracle PL/SQL?

    I have this request:
    select cso.branch,
      decode(NVL(cso.YES,0)+ NVL(cso.NO,0)+ NVL(cso.NA,0),0,'N','Y') ||' - '|| NVL(cso.officer,0) AS CSO_YN
    from (
    SELECT A.BRAN_CODE_PK as branch, a.emp_code_pk as officer, 
       COUNT(CASE WHEN D.STATUS = 1 THEN D.STATUS ELSE NULL END) YES,
       COUNT(CASE WHEN D.STATUS = 2 THEN D.STATUS ELSE NULL END) NO,
       COUNT(CASE WHEN D.STATUS = 3 THEN D.STATUS ELSE NULL END) NA
    FROM sales_team_accounts A, users U LEFT OUTER JOIN daily_check_lists D ON (D.USER_ID_PK = U.EMP_OFFICER_CODE
                                                                    and to_date(D.CHECK_LIST_DATE, 'DD-MON-YYYY') = '08-JUL-2010' ) -- date should be the parameter date)
    WHERE 1=1
    AND A.EMP_OFFICER_CODE = U.EMP_OFFICER_CODE
    AND A.sale_type_fk = 101 -- CSO
    AND A.SUPV_EMP_CODE_FK != 0
    and a.BRAN_CODE_PK = 1001
    group by A.BRAN_CODE_PK, a.emp_code_pk
    ) cso;
    The result of this query is the following:
    BRANCH     CSO_YN
    --------------------------------------
    1001             Y - 321
    1001             N - 335
    1001             Y - 90050
    1001             N - 303
    The scenario is, there could be maximum 7 officers in a branch,
    the total number of columns must therefore 7, and employee Y or N must be shaped in these 7 columns.

    So for each branch, it will always be 1 row to have 7 columns:
    So I want that it resembles the following:
    BRANCH     CSO1      CSO2      CSO3         CSO4       CSO5     CSO6     CSO7
    -----------------------------------------------------------------------------------------------------------
    1001        Y - 321    N - 335    Y - 90050    N - 303
    Need to do using only the PL/SQL query

    Published by: imation3m on October 22, 2010 12:21

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

  • Dynamic lines to column

    Hi all

    I need your help in the conversion of lines to the column for a specific group.

    This is the query
    SELECT lpad(papf.employee_number,6,'0') "File#",
      papf.full_name,
      DECODE(ppee.processing_type,'R',DECODE(ppee.element_name,'Regular Wages USD',peev.screen_entry_value,'Regular Salary USD',ROUND(peev.screen_entry_value/26,2),0),'N',peev.screen_entry_value,0) Element_Entry_Value,
      DECODE(ppee.element_name,'Regular Wages USD','H','Regular Salary USD','S','N') "Rate Type",
      PAAF.ASSIGNMENT_ID,
      ppee.element_name,
      ppee.processing_type,
      ppee.input_currency_code
    FROM pay_element_entry_values_f peev,
      pay_paywieeh_element_entries ppee,
      per_all_assignments_f paaf,
      per_all_people_f papf
    WHERE SYSDATE BETWEEN ppee.effective_start_date AND ppee.effective_end_date
    AND peev.element_entry_id=ppee.element_entry_id
    AND paaf.assignment_id   =ppee.assignment_id
    AND paaf.person_id       =papf.person_id
    AND sysdate BETWEEN paaf.effective_start_date AND paaf.effective_end_date
    AND sysdate BETWEEN papf.effective_start_date AND papf.effective_end_date
    AND sysdate BETWEEN peev.effective_start_date AND peev.effective_end_date
    AND ppee.input_currency_code='USD'
    ORDER BY ppee.assignment_id;
    Gives me set
    Example 1

    Name value rate Type Type assignment Employee Id number
    --------------------------------------------------------------------------------------------------------------------
    4 1 800 N 5 Bonus 64 yr employee
    4 employee 1 1063 N 6 months Bouns 64
    4 employee 1 24.04 H hourly Reg Sal 64
    5 employee 2 6923.08 S Reg Sal 65
    6 employee 3 5961.54 S Reg Sal 66
    6 employee 3 15000 N 6 months Bouns 66


    I need your help to convert out above to look similar to the following


    EMP Num name value Type Type Val 1 Type 1 Type 1 value 2 frequency rate rate Type 2 Type 2 Assignt Id
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    4 employee 1 24.04 H hourly Reg Sal 800 N 5 yr Bonus 1063 N my good 64 6
    5 employee 2 6923.08 S Reg Sal 65
    6 employee 3 5961.54 S Reg Sal 15000 N 6 mount good 66



    Example query of exit 2.

    Name value rate Type Type assignment Employee Id number
    --------------------------------------------------------------------------------------------------------------------
    4 1 800 N 5 Bonus 64 yr employee
    4 employee 1 1063 N 6 months Bouns 64
    4 employee 1 1345 N Bonus patent 64
    4 employee 1 24.04 H hourly Reg Sal 64
    5 employee 2 6923.08 S Reg Sal 65
    6 employee 3 5961.54 S Reg Sal 66
    6 employee 3 15000 N 6 months Bouns 66


    Desired by top of the query output. As you can see column have increased, as one more line for the same employee has increased

    ENu Nm Val RTy Ty Val1 RTy1 Ty1 Ty2 Ty3 Id RTy3 Val3 RTy2 Val2
    -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    4 E1 24.04 H RegH Sal 1063 N 6 my SNB 1345 N Pat good 800 N 64 5YB
    5     E2     6923.08     S     Reg Sal                                                  65
    6 E3 5961.54 S Reg Sal 15000 N 6 months Bouns 66


    Thanks in advance for help on this.

    Edited by: Prashant_Pathak may 18, 2010 15:23

    You can also you the package here to generate queries to PivotChart.

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:124812348063 #41097616566309

  • Lines in columns

    Hello

    I'm currently stuck with a problem when trying to convert some lines in columns, but the solutions I've found don't quite give me the result I want.

    Here's an example of how the transactional system stores its information.
    TRANS_REF   TRANS_LINE  ITEM_CODE   SUPP_DESCR                      PURCH_QTY
    PPI-026166  1           TELE1       Teléfono Celular Bmobile QW101  7000
    PPI-026166  2           TELE1       Teléfono Celular Motorola Spic  300
    PPI-026166  3           -           e                               0
    PPI-026166  4           TELE1       Teléfono Celular Huawei 6150 3  3777.7777
    PPI-026166  5           -           G, color azul/negro, Manos lib  0
    PPI-026166  6           -           res, manual inglés/español, Mi  0
    PPI-026166  7           -           cro SD de 2GB. Version SW: U61  0
    PPI-026166  8           -           50CAMB100                       0
    As you can see the transaction system is not any kind of ID for each item and each spans several lines, but the desired report would need the description be concatenated into a single description, like that I should only be left with 3 rows. The "good" is to identify the start of an element by the "TELE1' ITEM_CODE and not knowing how many lines the description will take.

    Concerning

    Hello

    vacadude wrote:
    Thanks much for the tips on how to post!

    Well, I use Oracle 11g,

    There is no Oracle 11f or 11 o'clock, so it is a bit ridiculous to say that you are using 11g. Say something like 'I'm using Oracle 11.2.0.1.0'.

    and the results you've posted, that's exactly what I'm looking for. I guess it would be with the LISTAGG function but I can't quite grasp its use, could you help me a bit with her?

    Here's a way to get these results using the LISTAGG:

    WITH     got_grp_id     AS
    (
         SELECT     transactions.*
         ,     COUNT (CASE WHEN item_code = 'TELE1' THEN 1 END)
                  OVER ( PARTITION BY  trans_ref
                          ORDER BY        trans_line
                        )       AS grp_id
         FROM    transactions
    )
    SELECT       trans_ref
    ,       MIN (trans_line)          AS first_trans_line
    ,       LISTAGG (supp_descr) WITHIN GROUP (ORDER BY trans_line)
                                          AS supp_descr
    ,       MAX (purch_qty)          AS purch_qty
    FROM       got_grp_id
    GROUP BY  trans_ref
    ,            grp_id
    ORDER BY  trans_ref
    ,            grp_id
    ;
    

    LISTAGG guess the order of the concatenated elements is always important, so he always requres «...» In the BOSOM OF THE GROUP (SOMETHING)". This differs from the more common aggregate functions (including MIN and MAX), where the order of the entries lines dioesn can't issue, and there is nothing to sort on an output, so these functions have «...» In the BOSOM OF THE GROUP (SOMETHING)".
    (Besides, if, for some reason, you really want to exit in a random order, you would have to say something like)

    LISTAGG (supp_descr)  WITHIN GROUP (ORDER BY  0)
    

    ).

    You always need a subquery as got_grp_id, because you need to GROUP BY something like grp_id, being derived from an anlalytic function, and GROUP BY is done before the analytical functions are calculated.
    With LISTAGG, you do not need a subquery as got_r_num. Using CONNECT BY, something very ordinary (such as integers consectuive) was necessary to get the lines in the order. LISTAGG using, what can go in a cllause ORDER BY is good enough.

  • Help: java.sql.SQLException: ORA-06550: line 1, column 7:, PLS-00201:

    Who can give me a hand to settle the question below? I use the db 11G for two or three days. This works. But now it displays information below, it blocks my server needs to be in place. Can anyone help to take a look? And explain to me what is meaning with below question?

    Thank you


    java.sql.SQLException: ORA-06550: line 1, column 7:
    PLS-00201: identifier ' INVALIDHTOMEH. KEEP ' should be declared

    oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
    11/08/05 02:18:17-oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:316)
    11/08/05 02:18:17-oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:282)
    11/08/05 02:18:17-oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:639)
    11/08/05 02:18:17-oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:184)
    11/08/05 02:18:17-oracle.jdbc.driver.T4CCallableStatement.execute_for_rows(T4CCallableStatement.java:873)
    11/08/05 02:18:17-oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1161)
    11/08/05 02:18:17-oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3001)
    11/08/05 02:18:17-oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3093)
    11/08/05 02:18:17-oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4286)
    11/08/05 02:18:17-com.agile.pc.cmserver.util.OracleIDGenerator.pinSequence(OracleIDGenerator.java:245)
    11/08/05-02:18:17-com.agile.pc.cmserver.util.OracleIDGenerator. < init > (OracleIDGenerator.java:62)
    11/08/05 02:18:17-com.agile.pc.cmserver.util.CMUtilReflection.getOracleIDGenerator(CMUtilReflection.java:79)
    11/08/05 02:18:17-com.agile.util.dao.IDGenerator.getNewInstance(IDGenerator.java:78)
    11/08/05 02:18:17-com.agile.util.dao.IDGenerator.getInstance(IDGenerator.java:66)
    11/08/05 02:18:17-com.agile.util.dao.IDGenerator.getNextID(IDGenerator.java:91)
    11/08/05-02:18:17-com.agile.util.AppServerId. < clinit > (AppServerId.java:14)
    11/08/05 02:18:17-com.agile.startup.PCMStartupImpl.start(PCMStartupImpl.java:115)
    11/08/05 02:18:17-com.agile.ui.pcm.InitServlet.init(InitServlet.java:63)
    11/08/05 02:18:17-com.evermind.server.http.HttpApplication.loadServlet(HttpApplication.java:2379)
    11/08/05 02:18:17-com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4830)
    11/08/05 02:18:17-com.evermind.server.http.HttpApplication.findServlet(HttpApplication.java:4754)
    11/08/05 02:18:17-com.evermind.server.http.HttpApplication.initPreloadServlets(HttpApplication.java:4942)
    11/08/05 02:18:17-com.evermind.server.http.HttpApplication.initDynamic(HttpApplication.java:1144)
    11/08/05-02:18:17-com.evermind.server.http.HttpApplication. < init > (HttpApplication.java:741)
    11/08/05 02:18:17-com.evermind.server.ApplicationStateRunning.getHttpApplication(ApplicationStateRunning.java:431)
    11/08/05 02:18:17-com.evermind.server.Application.getHttpApplication(Application.java:586)
    11/08/05 02:18:17-com.evermind.server.http.HttpSite$ HttpApplicationRunTimeReference.createHttpApplicationFromReference (HttpSite.java:1987)
    11/08/05 02:18:17-com.evermind.server.http.HttpSite$ HttpApplicationRunTimeReference. < init > (HttpSite.java:1906)
    11/08/05 02:18:17-com.evermind.server.http.HttpSite.initApplications(HttpSite.java:643)
    11/08/05 02:18:17-com.evermind.server.http.HttpSite.setConfig(HttpSite.java:290)
    11/08/05 02:18:17-com.evermind.server.http.HttpServer.setSites(HttpServer.java:270)
    11/08/05 02:18:17-com.evermind.server.http.HttpServer.setConfig(HttpServer.java:177)
    11/08/05 02:18:17-com.evermind.server.ApplicationServer.initializeHttp(ApplicationServer.java:2493)
    11/08/05 02:18:17-com.evermind.server.ApplicationServer.setConfig(ApplicationServer.java:1042)
    11/08/05 02:18:17-com.evermind.server.ApplicationServerLauncher.run(ApplicationServerLauncher.java:131)

    Published by: user774630 on November 4, 2008 18:57

    # com.agile.pc.cmserver.util.OracleIDGenerator.pinSequence(OracleIDGenerator.java:245)

    This method tries to pin a sequence in the Shared Pool so that it is not recharged. Reloading can cause sequence numbers to be ignored, if I remember correctly.
    Pinning is done using packed the INVALIDHTOMEH procedure. KEEP. The error is reported because either the package INVALIDHTOMEH is not created in the database (the $ORACLE_HOME/rdbms/admin/dbmspool.sql script creates) or the user who connects to the database have not run privilege for the package.

    Note that the package has access to the shared swimming pool. Execute privilege to grant only trusted users.

    -Sergiusz

  • Matrix - vector lines and columns

    M1 (3,2) gives the element of line 3, column 2

    M1 (2) gives the second row of a matrix (as a vector line)

    Is there a way to return a column (other than transpose, store again and using the method above on the transposed matrix)?

    Tim Wessman wrote:

    Assuming that first here...

    Col(M1,1)

    Row(M1,1)

    @ Tim,.

    As Mmmm - created a post on the 39gii and commented on a post on the 39gii, this one is perhaps more likely to be on the 39gii?

    I think that your presumption re - expresses my presumption that the 39gii becomes brother forgot the premium?

    @ Mmmm.

    Try M1 (-c), where C is desired column number. For example M1(-2) for column 2.

  • P7-1298cb: Multi-color flickering lines in columns displayed on the screen after upgrade Windows 10.

    I upgraded Windows Windows 8.1 1O.  I've updated the drivers.  The monitor multicolored poster of fine lines in columns.  The lines of twinkle randomly.  The monitor is a diagonal LED of 2711 x 27 inch HP (XP600A) screen.  It is not that there is a specific monitor for Windows 10 driver.  Any suggestions on how to fix this?

    HI @TLL2016,

    Thanks for getting back to me.

    There is no update BIOS, but there is more recent graphics driver.

    Here is a link the download AMD UMA Graphics Driver.

    Just to check the monitor, here is a document for display quality problems.

    Please keep me informed of the progress of things.

    If you need help, let me know and I will gladly make all that I can to help you.

    Please let me know if that solves the problem by marking this post as "accept as a Solution.
    To simply say thank you, click the Thumbs up below!

    Thank you.

  • How to write express line and column of the tables headers to a file

    HI guys, I work with that express table and display data using the express table. What I want to do, is that when I press save button results data in the specific table must be written to a text file. I am able to write the text file, but only the data is written. Y at - there a possiblity that I can also write lines and column headers and the data in the text file. Kindly guide me in this regard as soon as possible. I enclose the image also. Please watch this and guide me.

    Cordially Ehtisham Safdar.

    Hello

    Sorry for the late reply. Here is the VI, I hope it works for you. Rather than each element of the index and the addition of the row header, take advantage of the available icons and play with the nodes of property for a good solution.

    Concerning

    Gaze

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

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

  • Sort sort the columns number of lines n columns in the RTF PivotTable but hide them.

    Hello

    I'm trying to sort on the columns number of sort for lines n columns in the PivotTable but hide them. Any help appreciated.

    Attached model RTF, XML and output required. Thank you

    Please check your email that I have forwarded to update the model.

    by default, it performs a sort on the column, we used to pivot rows and columns. If we need custom sort, we must specify that column in the logic that was present in the C form field.

    by default, you are as below

    Custom sort

    {INDUSTRY_sort, o = a, t = n} « ; » MONTHS {Month_sort, o = a, t = n} '; SALES '; "' sum '? >

  • Write a SQL query with lines in columns

    All the

    I need help in writing a SQL query with lines in columns, let give u an example...

    drop table activity;

    CREATE TABLE 'ACTIVITY '.

    (

    "PROJECT_WID" NUMBER (22.0) NOT NULL,

    VARCHAR2 (150 CHAR) "PROJECT_NO."

    VARCHAR2 (800 CHAR) 'NAME '.

    );

    Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (1683691, '10007', 12-121');

    Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (1684994, '10008', 12-122');

    Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (1686296, '10009', 12-123');

    Insert in the ACTIVITY (PROJECT_WID, PROJECT_NO, NAME) values (2225222, '9040', 12-124');

    drop table lonet;

    CREATE TABLE 'LONET.

    (

    VARCHAR2 (150 CHAR) "NAME."

    NUMBER OF THE "ROOT."

    VARCHAR2 (150 CHAR) "ENTRYVALUE".

    );

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("GAC", 1683691, "LDE");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('NAM', 1683691, 'LME');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('BAG', 1683691, 'ICE');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('PAP', 1683691, 'IKE');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('NAM', 1686291, "QTY");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('PAP', 1686291, 'MAX');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("GAC", 1684994, "MTE");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('PAP', 1684994, 'MAC');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('FMT', 1684994, 'NICE');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('FMR', 1684994, 'RAY');

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ('BAG', 1686296, "CAQ");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("PAP", 1686296, "QAQ");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("VANESSA", 1686296, "THEW");

    INSERT INTO LONET (NAME, ROOT, ENTRYVALUE) VALUES ("ANDR", 1686296, "REYL");

    commit;

    Link: activity.project_wid = lonet.root

    look like output

    Project_wid Project_no NAME GAC NAM BAG RAC
    16836911000712-121LDELMELCELKE
    16849941000812-122MTEnullnullMAC
    16862961000912-123nullnullCAQQAQ
    2225222904012-124nullnullnullnull

    two problems, in that I am running

    1. I dono how simply we can convert rows to columns

    2. for root = 1683691, there are double NAM and RAC in lonet table... ideally these data should not be there, but since its here, we can take a MAX so that it returns a value

    3. There are undesirables who should be ignored

    Once again my thought process is that we join the activity and 4 alias table lonet.

    ask for your help in this

    Thank you

    Hello

    This is called pivoting.

    Here's a way to do it:

    WITH relevant_data AS

    (

    SELECT a.project_wid, a.project_no, b.SID

    , l.name AS lonet_name, l.entryvalue

    Activity one

    LEFT OUTER JOIN lonet l.root = a.project_wid l

    )

    SELECT *.

    OF relevant_data

    PIVOT (MAX (entryvalue)

    FOR lonet_name IN ("GAC" IN the gac

    "NAM" AS nam

    'BAG' IN the bag

    "RAC" AS cars

    )

    )

    ORDER BY project_wid

    ;

    Output:

    PROJECT_WID PROJECT_NO GAC NAM BAG RAC NAME

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

    1683691 12 - 10007 121 LDE LME LCE LKE

    1684994 MAC MTE 10008 12-122

    1686296 12 - 10009 123 QAC QAQ

    2225222 9040 12 - 124

    To learn more about swivel, see the FAQ in the Forum: Re: 4. How can I convert rows to columns?

    Thanks for posting the CREATE TABLE and INSERT statements; It's very useful!

  • error handle output line 45 / column 9 / errors/warnings - tag must be associated, missing: [&lt; /li &gt; &lt; /li &gt; &lt; /li &gt; &lt; /li &gt;]

    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

  • AWK print 1st line of column 2

    hope I can get help with awk unix guys here

    trying to get the line 2, column 1 leaving an output of l - esxcfg-vswitch

    basically by train to get the ID of dvport vmnic0

    esxcfg-vswitch - l | grep vmnic0 | AWK '{print $1} '.

    column 1 shows

    and

    esxcfg-vswitch - l | grep vmnic0 | AWK 'NR == 2'

    line 2 shows

    How to show a line of column 1 2 only?

    AWK 'NR is 2 {print $1}'

Maybe you are looking for