need of a query to row to the column transformation

 
SELECT friday_date FROM t2;
Data in the table:
02/01/2009
09/01/2009
16/01/2009...

I need a query to get the result below fashion

Column
----------
1/2/20091/9/20091/16/2009

I tried to PIVOT and TRANSPOSES, this is impossible. I think because it's a date, maybe.
I tried code below also, but CONNECT_BY_ISLEAF will not work on "ORA-00904:"CONNECT_BY_ISLEAF": invalid identifier.
SELECT ltrim(sys_connect_by_path(FRIDAY_DATE,','),',') FRIDAY_DATE
       FROM (
        SELECT row_number() OVER(ORDER BY FRIDAY_DATE) rno,
               FRIDAY_DATE
          FROM t2
       )
      WHERE CONNECT_BY_ISLEAF = '1'
      start WITH rno = '1'
    connect BY rno = PRIOR rno+1;
Thank you
SQL>  WITH t2 AS (      SELECT TO_CHAR (
                                          NEXT_DAY (
                                               DATE '2009-01-01' + (LEVEL - 1) * 7,
                                               'friday'
                                          ),
                                          'mm/dd/yyyy'
                                     )
                                          friday_date
                              FROM DUAL
                    CONNECT BY LEVEL <= (DATE '2009-12-31' - DATE '2009-01-01') / 7)
---
---
SELECT RTRIM (
                XMLAGG (XMLELEMENT (
                                   e,
                                   friday_date || ','
                              )).EXTRACT ('//text()'),
                ','
           )
                COLUMN_VALUE
  FROM t2

COLUMN_VALUE
--------------------------------------------------------------------------------
01/02/2009,01/09/2009,01/16/2009,01/23/2009,01/30/2009,02/06/2009,02/13/2009,02/
20/2009,02/27/2009,03/06/2009,03/13/2009,03/20/2009,03/27/2009,04/03/2009,04/10/
2009,04/17/2009,04/24/2009,05/01/2009,05/08/2009,05/15/2009,05/22/2009,05/29/200
9,06/05/2009,06/12/2009,06/19/2009,06/26/2009,07/03/2009,07/10/2009,07/17/2009,0
7/24/2009,07/31/2009,08/07/2009,08/14/2009,08/21/2009,08/28/2009,09/04/2009,09/1
1/2009,09/18/2009,09/25/2009,10/02/2009,10/09/2009,10/16/2009,10/23/2009,10/30/2
009,11/06/2009,11/13/2009,11/20/2009,11/27/2009,12/04/2009,12/11/2009,12/18/2009
,12/25/2009                                                                     

1 row selected.

Tags: Database

Similar Questions

  • Returns all duplicate rows, where the columns correspond

    Dear members,

    I have a table that contains duplicates, and the query should return only the rows where the columns correspond...

    create master table (varchar2 (10) firstname, lastname varchar2 (10), code VARCHAR2 (3), place varchar2 (10));

    insert into Master values ('bob', 'John', '1', 'atlanta');
    insert into Master values ('bob', 'John', '1', 'atlanta');
    insert into Master values ('bob', 'John', '1', 'atlanta');

    insert into Master values ('test', 'John', '1', 'atlanta');

    Insert into master values('bob','john','1','bank');


    The application should we 3 rows.

    Bob-john-1-atlanta
    Bob-john-1-atlanta
    Bob-john-1-atlanta


    I tried a few changes to query such as select * from master M, mater n where m.firstname = n.firstname and...

    Is there another way to do this...

    Thanks in advance...
    select  firstname,
            lastname,
            code,
            place
      from  (
             select  m.*,
                     count(*) over(partition by firstname,lastname,code,place) cnt
               from  master m
            )
      where cnt > 1
      order by firstname,
               lastname,
               code,
               place
    /
    
    FIRSTNAME  LASTNAME   COD PLACE
    ---------- ---------- --- ----------
    bob        john       1   atlanta
    bob        john       1   atlanta
    bob        john       1   atlanta
    
    SQL> 
    

    SY.

  • I need to convert PDF to Excel, however, the columns and tabs make many merged cells and the number of columns empty. In addition to not separate the columns properly, I see many not separate lines together in the same cell. I think same as Adobe Acrobat

    I need to convert PDF to Excel, however, the columns and tabs make many merged cells and the number of columns empty. In addition to not separate the columns properly, I see many not separate lines together in the same cell. I even think that Adobe Acrobat Pro DC has limits. There is no way to set what points in columns to force the column break? Or create several columns that are unnecessary? How column in Excel, size fixed when import us text and define where breaks have columns of text?

    Google Tradutor para empresas:Google para appsTradutor sitesGlobal market Finder traducao Toolkit

    Acts traducao Instantaneasobre o Google TradutorCelularComunidadePrivacidade e TermosAjudaEnviar comments

    PDF does not contain columns, lines, formats, styles or other aspects of word processing or spreadsheet file formats.

    This is because the PDF is decidedly not a file format of word processor or a spreadsheet or something 'like' one of these.

    (see ISO 32000 for what PDF "is")

    Which allows to optimize the export of the content of a page PDF is to start with that tag well formed PDF (ISO 14289-1, PDF/UA-1).

    Without that export is what it is and we performs the cleanup of any necessary content using the native application for the export of files (MS Word or Excel).

    Be well...

  • Query that count only the column null lines

    create table test
    (a varchar2 (10))
    b varchar2 (10),
    c varchar2 (10),
    d varchar2 (10),
    e varchar2 (10));


    SQL > DESC TEST
    Name Null? Type
    ------------------------------- -------- ----
    A VARCHAR2 (10)
    B VARCHAR2 (10)
    C VARCHAR2 (10)
    D VARCHAR2 (10)
    E VARCHAR2 (10)

    SQL > SELECT * FROM TEST;

    A B C D E
    ---------- ---------- ---------- ---------- ----------
    A1 - A3 A4-
    B1 - B3, B4-
    C1 - C3 C4-
    D1 - D4 D5
    -E2 - E4 E5


    I want an application that only count the rows of the column as null

    A B C D E
    --- ---- ----- ------ -------
    1 4 2 0 3

    Published by: Nilesh hole, Pune, India, on August 28, 2009 12:30
    select SUM(case when a is null then 1 else 0 end)
          ,SUM(case when b is null then 1 else 0 end)
          ,SUM(case when c is null then 1 else 0 end)
          ,SUM(case when d is null then 1 else 0 end)
          ,SUM(case when e is null then 1 else 0 end)
    from TEST
    /
    

    Published by: Toon Koppelaars August 28, 2009 09:07

  • PL/SQL Query return function, adding the column links

    Hi all

    I'm working on a SQL report with the area type = function from PL/SQL Query to return
    All columns are generated dynamically based on my mapping table and a column of ID.
    So whenever the page is loaded, according to the ID mapping table returns a set of columns in a particular order.
    So not only the columns are dynamic, but the order of the columns varies also.
    But the first 1 column is standard (it doesn't come from the mapping table) and is coded in my pl/sql block hard.

    I'm fighting with the addition of a link to this column. The link must be a Javascript function which takes the parameters in the form of 2 columns in the mapping table.
    My pl/sql block is something like that...
    v_select := 'SELECT <g href=javascript:f_report1(#map_id#,#comments#)><img src=""></a> as report1, ';  // g=a
    v_cols := 'contains all columns from the mapping table based on a ID(hidden item)';
    v_from := 'FROM table';
    v_where := 'where condition is put in here';
    v_query := v_select||v_from||v_where;
    return v_query;
    Now, I'm not able to transmit the values of this #map_id # and #comments # correctly. I tried so many different combinations of channels, but could not make it work.

    I'm not sure that the order of this map_id and commentscolumn and therefore cannot connect through the report attributes.
    How can I go to a column value to the function?



    Thank you
    Dippy

    This should work if all goes well:

    v_select := q'[ SELECT '' as chart, ]';
    

    Published by: Dimitri Gielis on May 20, 2010 20:10

  • View Blackberry Java Sqlite query result rows in the form of pages

    How can I display the rows resulting from the query sqlite one at a time in the form of question pages where a buttonfield (then) displays the next line (question) when you press. I was able to display all the rows at once with the following code:

    Statement st = null;
    try {}
    St = db.createStatement ("SELECT * FROM Questions by Qid asc");
    St.Prepare ();
    Cursor c = st.getCursor ();
    If (c == null) {}
    Dialog.Alert ("unable to retrieve from the database");
    }
    Line r;
    {while (c.Next ())}
    r = c.getRow ();

    String opt = "option" + r.getInteger (0);
    Option RadioButtonGroup = new RadioButtonGroup();
    Add (new LabelField (r.getInteger (0) + "." + r.getString (1)));
    Add (new RadioButtonField (r.getString (2), option, false));
    Add (new RadioButtonField (r.getString (3), option, false));
    Add (new RadioButtonField (r.getString (4), option, false));
    Add (new SeparatorField());
    }
    } catch (Exception e) {}
    e.printStackTrace ();
    } {Finally
    try {}
    St.Close ();
    } catch (DatabaseException e) {}
    }
    }

    But no progress with splitting into separate view. Do you know how to go about it?

    I thought the usual way to proceed would be for the SQL query to provide lines to return to the screen, and then the screen would have a loop by pushing another modal screen with the following Question.  If this player from the screen not from the query.  Who is?

  • 2540 DeskJet not print all rows in the column

    I am satisfied with my new 2540 Deskjet, except on the simple Excel documents it prints only a portion of the lines even if the grid is checked. This never happened with my old dell printer.

    Hi CathB123,

    Welcome to the HP Forums!

    If printing works well in other programs, I recommend this site, print gridlines in a worksheet. I would also try using the HP print and Scan Doctor, in which case there may be a driver conflict.

    Otherwise, if it does not help, please contact Microsoft Office technical support. The Agency supports, as I am not familiar with Excel.

    Good luck!

  • I want to update a column in any changes made to a row and the column of the same row must be updated with the new status

    Hi all

    I am new in the form of Oracle, I have a question,

    in oracle from(10G) now I show an entire table, when I update a line, then in that same line, there is a column named as status, must got the update automatically with the value 'NEW '.

    Can someone help me how to perform this task.

    If any body knows then please reply as soon as POSSIBLE.

    Thank you

    Ashish

    1003500 wrote:

    Hi all

    I am new in the form of Oracle, I have a question,

    in oracle from(10G) now I show an entire table, when I update a line, then in that same line, there is a column named as status, must got the update automatically with the value 'NEW '.

    Can someone help me how to perform this task.

    If any body knows then please reply as soon as POSSIBLE.

    Thank you

    Ashish

    Ashish

    Try this

    / * write the following code in Post-Text-Item at the block level * /.

    IF: System.Record_Status IN ("MODIFIED", "INSERT") THEN

    : your_block_name.column_name: = 'NEW';

    END IF;

    Hamid

  • Different formulas for different rows in the column of the formula

    Is this possible? If possible, how?

    Hello

    I still don't think that the new version has something we have in FR.
    We have only one formula per column of formulas in a web form to the difference in FR.

    Thank you
    Sourabh.

  • SQL query for data of the quarter... Help, please

    Dear Experts,

    Please help with this query...

    I have data as below:

    YearQuarterMRRMORR %
    -------------------
    20121ST QUARTER10
    Q230
    Q350
    Q460
    20131ST QUARTER20
    Q230

    Now I need to caluclate MORR % as column values below

    for 2012 T2 MRR % = (Q2MRR-Q1MRR) / (30-10) Q1 * 100 / 10 * 100

    for 2012, T3 MRR % = (Q4MRR-Q3MRR) / Q2 * 100

    for 2012 T4 MRR % = (Q1MRR-Q4MRR) / Q1 * 100 here q1 2013 and the 4th quarter of 2012...

    like this he wll go...

    Please help with me query calculate values in the column % MRR.

    Best regards

    ASP.

    Maybe NOT TESTED! No database at your fingertips

    Select the year, quarter, mrr,.

    ratio_to_report (q_mrr) on pct_mrr (partition by order of the year by quarter)

    (select the year, quarter, mrr,)

    MRR - lag (mrr, 1, 0) on q_mrr (partition by order of the year by quarter)

    t

    )

    Concerning

    Etbin

  • Need to create a new line in the table with the same data as the primary key, but new PK

    Hello gurus,

    I have a table with a column as a primary key, I need to create a new row in the table, but with the same data in one of the lines, but with different primary keys, focus a double row with key primary diferent...

    Any ideas of how it can be done without much complication?

    Thanks in advance for your answer.

    Agress,
    Karim idrissi

    user9970447 wrote:
    Hello gurus,

    I have a table with a column as a primary key, I need to create a new row in the table, but with the same data in one of the lines, but with different primary keys, focus a double row with key primary diferent...

    Any ideas of how it can be done without much complication?

    Thanks in advance for your answer.

    Agress,
    Karim idrissi

    something like

    insert into mytable values ('literal for new pk',
                                           select non-pk-1,
                                                    non-pk-2,
                                                    non-pk-n
                                           from mytable
                                           where pk-col = 'literal for existing pk')
    
  • Error when selecting all the columns in the table

    Hi all

    When I write a query by selecting all the columns of the table fromo using * function as well as another new column, I get the error,

    Select *, to_char (hiredate, 'fmday') day

    WCP

    where to_char (hiredate, 'fmday') ('Monday');

    ERROR on line 1:

    ORA-00923: THE KEYWORD not found where expected

    I need all the columns in the table with the column user-defined 'day '. Is there a way I can get the result like this?

    Hello

    padders wrote:

    Alias table to use...

    Or the name of the table, for example

    Select emp.*, to_char (hiredate, "fmday") as day

    WCP

    where to_char (hiredate, 'fmday') ('Monday');

    The bottom line is that * must be qualified (with a table name or alias) when the SELECT clause includes anything else besides *.

  • Change data type for the column in a table - Oracle 8i

    Team,

    I need to change a VARCHAR2 column in number.

    ALTER table xyz change number abc;

    By giving the above statement, it says I need empty this column before you change.

    I can't change the data type before emptying this column.

    Please indicate any other solution. Give me some suggestions.

    Empty the column for me here BIG task.

    user11081688 wrote:
    I can't change the data type before emptying this column.

    Not according to the documentation:

    You can change the data type of any column or decrease the size of the entire column if all rows in the column contains NULL values.

    Please indicate any other solution. Give me some suggestions.

    You can add another column with the correct data type.

    ALTER TABLE xyz ADD COLUMN def NUMBER;
    UPDATE TABLE xyz SET def = TO_NUMBER(abc);
    ALTER TABLE xyz DROP COLUMN abc;
    ALTER TABLE xyz ADD COLUMN abc NUMBER;
    UPDATE TABLE xyz SET abc = def;
    ALTER TABEL xyz DROP COLUMN xyz;
    

    If I remember correctly, Oracle 8i does not support the change of name of column if this solution is a bit more complicated than 9i and above. Another option would be to create a new table with CREATE TABLE AS... SELECT, drop the old one and rename a new one to the old.

  • Deactivation of the column in a table based on the setting in the search box

    Hi all

    I use Oracle Apex 4.1. I have two region

    1. search box

    2. in the form of a table

    In the search box, I have a LOV field where the user can select the value. Based on this LOV in the search box, tabular column f06 must disable or read-only.

    For example if I select THREE in LOV then only column f06 is expected on the other it must disable. How to get there.

    Thanks in advance

    Ravi

    Hi Bobo,

    Hope link below will solve your query.

    Disable the column in a table.

    BR,

    Patrick

  • Deriving from the value of the column totals

    BI Publisher 11g:

    I have the next report, that I generated:

    BOX TYPE NUMBER OF BOXES COST COST PER BOX
    A10$100$10
    B20$140$7
    TOTAL30$240$17

    My problem is that in the TOTAL row in the column COST PER BOX, the value shouldn't be that is to say $17 ($10 + $7) it should be actually IE $8 ($240 / $30). Does anyone know how to calculate the correct value.

    Assuming that this structure of xml data:

    A

    10

    100

    B

    20

    140

    You can use the following code to get the values:

    row1:  

    row2: 

    Thank you

    Bipuser

Maybe you are looking for