Rows to columns/Transpose the records Query and Display output

hi ,
can anyone help me query this and transpose it to this format?
i am still a beginner in sql.
thanks for help!
Rows to columns/Transpose the records Query and Display output
id     startdate     endate                    
1111     1/2/2001     11/3/2001                    
1111     2/5/2002     4/3/2002                    
1111     2/6/2000     2/5/2001                    
3333     5/2/2003     11/3/2003                    
3333     6/2/2003     12/3/2003                    
3333     2/6/2005     2/5/2005                    
desired output     
id     startdate1     endate1     startdate2     endate2     startdate3     endate3
1111     1/2/2001     11/3/2001     2/5/2002     4/3/2002     2/6/2000     2/5/2001
3333     5/2/2003     11/3/2003     6/2/2003     12/3/2003     2/6/2005     2/5/2005

Have you only 3 dates for each id ?
So, try :
SQL> l
  1  with tbl as
  2  (select 1111 as id, to_date('01/02/2001','DD/MM/YYYY') startdate, to_date('11/03/2001','DD/MM/YYYY') enddate from dual union all
  3  select 1111 as id, to_date('02/05/2002','DD/MM/YYYY') startdate, to_date('04/03/2002','DD/MM/YYYY') enddate from dual union all
  4  select 1111 as id, to_date('02/06/2000','DD/MM/YYYY') startdate, to_date('02/05/2001','DD/MM/YYYY') enddate from dual union all
  5  select 3333 as id, to_date('05/02/2003','DD/MM/YYYY') startdate, to_date('11/03/2003','DD/MM/YYYY') enddate from dual union all
  6  select 3333 as id, to_date('06/02/2003','DD/MM/YYYY') startdate, to_date('12/03/2003','DD/MM/YYYY') enddate from dual union all
  7  select 3333 as id, to_date('02/06/2005','DD/MM/YYYY') startdate, to_date('02/05/2005','DD/MM/YYYY') enddate from dual )
  8  select id, max(decode(dr,1,startdate)) start1,
  9             max(decode(dr,1,enddate)) end1,
10             max(decode(dr,2,startdate)) start2,
11             max(decode(dr,2,enddate)) end2,
12             max(decode(dr,3,startdate)) start3,
13             max(decode(dr,3,enddate)) end3
14  from (select id, startdate,enddate, dense_rank() over (partition by id order by startdate) dr from tbl)
15* group by id
SQL> /
                                                ID START1   END1     START2   END2     START3   END3
                                              1111 02/06/00 02/05/01 01/02/01 11/03/01 02/05/02 04/03/02
                                              3333 05/02/03 11/03/03 06/02/03 12/03/03 02/06/05 02/05/05
SQL> HTH,
Nicolas.

Similar Messages

  • Warning: No new rows or columns because the axis is not input-ready

    Hello all,
    I have a planning application that plan against multiple years. This is done using a query that uses an analysis web item with its properties set to enable multiple new rows e.g. 2 new rows. Right now I have an issue whereby those 2 new rows will only appear if I restrict the report to a single year and if I were to select 2 or more years I get this warning message u201CNo new rows or columns because the axis is not input-readyu201D and those 2 rows will disappear.
    Anybody have any idea whatu2019s going on? Thanks.

    Hi,
    note 1149346 explains when new lines are possible:
    https://service.sap.com/sap/support/notes/1149346
    Regards,
    Gregor

  • No new rows or columns because the axis is not input-ready

    Hi Gurus,
    I have a problem when I am modelling the Order and Revenue Planning.
    In my model I have Base Unit and Currency as Unit characterstics.
    When I take Currency as INR and Base Unit Multiple Values then I can create a new row in my planning layout.
    If I take currecy also multiple values, system is throwing following message "No new rows or columns because the axis is not input-ready" and not allowing me to create new rows(rather it is not displaying the new rows). But Query is Input Ready.
    Could any one suggest solution for this.....
    Waiting for your reply......
    Thanks and Regards,
    Arun.

    Hi Arun,
    I know exactly what you are trying to do.  Don' t waste your time any further on it.   The story would have been different if the entire layout was on a single currency(header or filtered).
    For your problem....
    First of all you cannot use 0AMOUNT.  As it will not allow you to seperate 0Currency from 0Amount as it is already defined in the 0Amount Infoobject. Even if you try to add 0Currency AGAIN as a "separate" characteristic in the row of Query.  So you will have to now provide 2 currency values to 0Currency(in the row) as well as 0Currency in the 0Amount (which you cannot select in Query Designer).  Because the system will still be looking for 0Currency value embedded to 0Amount.  The only way you can do is by using a Custom Key Figure with No Dim.  I mean, ZAmount with no Unit/Currency in the infoobject definition. 
    Let Currency be an attribute of Order.  Display this currency attribute in the row of the layout, just so the users know which currency they are going to enter values on.  It(currency) is only for informational purpose and not to think that the values entered initially by the users are stored along with the same currency.  And then after the user enters values on this ZAMOUNT, upon save use Fox behind the scene to copy this over to real "0Amount".  Fox should read the Order currency(attribute) and store the currency into along with the 0Amount(and 0currency).  All other Char stored by user should be copied as is in the Fox.
    The same logic applies to 0Quantity(with unit). 
    Hope this solution works for you.  Let us know if this is possible.
    Rocky

  • No new rows or columns because the axis is not input-ready - error

    hi,
    can any one tell me how to solve this.
    i am able to change the data but not able to add new rows or columns to the analysis item.
    i am getting following error
    No new rows or columns because the axis is not input-ready
    how to solve this.
    please suggest me.
    i will assign points.

    Hello venkat,
    robably the definition of rows and columns is to complicated for the system to read.
    Do you want to add a new row or a new column?
    how are the existing rows or columns defined?
    It does work, if you have included only characteristics into row / column and you are using key or key+text to be shown in your query.
    regards
    Cornelia

  • How to use a calculated column in the same query

    Hi All,
    I need some help with using a calculated column in the same query.
    For eq
    I am joining a couple of tables and some of the select columns are calculated based on the columns of the tables and i want a new column in the same query to use this calculated feild in some other calcualtion.
    something like this...
    select (12+3) as Sum1, (12-3) as Sum2, (Sum1 + Sum2 ) as Sum3
    from dual
    or
    select (12+3) as "Sum1", (12-3) as "Sum2", CASE WHEN ( "Sum1" / "Sum2" * 100 > 0 ) THEN 'Yes' ELSE 'No' END
    from dual
    Thanks

    user548171 wrote:
    select (12+3) as Sum1, (12-3) as Sum2, (Sum1 + Sum2 ) as Sum3
    from dual
    or
    select (12+3) as "Sum1", (12-3) as "Sum2", CASE WHEN ( "Sum1" / "Sum2" * 100 > 0 ) THEN 'Yes' ELSE 'No' END
    from dual
    ThanksWhat about just repeating the column values:
    select (12+3) as "Sum1", (12-3) as "Sum2", CASE WHEN ( (12+3) / (12-3)  * 100  > 0 )  THEN 'Yes' ELSE 'No'  END FROM DUAL

  • Nsert/Update and Add Column at the same Table and at the "same" Time

    Hello,
    I want Insert/Update and Add Column at the same Table and at the "same" Time but in different sessions.
    Example:
    At first the "insert/update" statement:
    Insert into TestTable (Testid,Value) values (1,5105);
    After that the "add" statement:
    Alter table TestTable add TestColumn number;
    - sadly now I get the message: ORA-00054: resource busy and acquire with NOWAIT specified
    "insert/update" statement:
    Insert into TestTable (Testid,Value) values (2,1135);
    After that the execute commit.
    I don't know when the first session set the commit statement so I want that the DB the "Alter Table..." statement execute if it's possible.
    If it's possible I want to save a repeat loop with the "Alter Table..." statemtent.
    Thanks for ideas

    Well I want to walk in the rain without and umbrella and still stay dry, but it ain't gonna happen.
    You can't run a DDL statement against a table with transactions pending. Session 2 has to wait until session commits or rollbacks (or until the session is killed). That's just the way it is.
    This makes sense if you think about it. The data dictionary has to be consistent across all sessions. If session 2 was allowed to change the table structure whilst session 1 has a pending transaction then the database is in an inconsistent state. This is easier to see if you consider the reverse situation - the ALTER TABLE statement run by session 2 does a DROP COLUMN TESTID rather than adding a column: now what should happen to session 1's INSERT statement? You have retrospectively invalidated a statement that was perfectly legal when it was executed.
    If it's possible I want to save a repeat loop with the "Alter Table..." statemtent.Fnord.
    Cheers, APC

  • How to retrieve Task Lists from All Subsites to the Parent Site and display in Grid view using CAML Query

    How to retrieve Task Lists from All Subsites to the Parent Site and display in  Grid view using CAML Query + object model

    do u just want task list or items under task list for all subsites
    for items use spsitedataquery ref
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsitedataquery.aspx use recursive to get it from alll subsite under site collection
    for tasklist only u can a simply use a for loop to find in all subsite
    Manish Sati

  • Garage Band,  I am using an MBOX with a digi design audio core as a mic interface to recod into Garage Band.  Now when I Change the preferences to use the MBOX I can not move the recorder slider and there is no sound going into garage band?  Any solutions

    Garage Band,  I am using an MBOX with a digi design audio core as a mic interface to recod into Garage Band.  Now when I Change the preferences to use the MBOX I can not move the recorder slider and there is no sound going into garage band?  Any solutions

    10.5.8 with latest garageband 5.1 with MBOX 1. On Nov 4.09 I did a software update, now i get no output volume or input volume to the computer itself. I get it from head phones from my mbox, but not to the computer. Before the software update It worked great. I've tried upgrading software through digidesign .com, but they dont seem to have one for what i need. any way to get my old garage band back? go from 5.1 to earlier? Or maybe it was the upgrade to 10.5.8. update? Can i go back in time lol?
    Any help would be appreciated
    BTW
    Ive tried all the system sound prefs, and garage band drivers. Back and forth.
    cheers
    ds

  • In FCP.  Trying to record voiceover.  Go to Window, Record Audio, see the record window and FCP quits in about 2 seconds.

    Trying to record audio voiceover.  Go to Window, Select Record Audio, see the record window and FCP quits in about 2 seconds.  Can't get started??

    I think you've got the right driver selected, otherwise it wouln't work at all. The single most obvious thing to ask you though (I'm sorry if this is too basic) is where you have the pan controls set to? To get each mic to record on a single channel, you'd have to have one panned hard left and the other panned hard right. If you leave them both panned dead centre, that's exactly what you get - both mics on both channels.

  • Retrieve data from 2 columns of 2 different tables and display in 1 column

    Hi,
    Is it possible to retrieve data from 2 different columns of 2 different tables and display it in the same column of a datablock in a form.
    For example:
    Table A
    Col1
    1
    2
    3
    Table B
    Col1
    2
    4
    5
    The column from the datablock in the form should display the following:
    1
    2
    3
    2
    4
    5

    You can create a view
    select ... from table_a
    union
    select ... from table_b
    and base the block on that.
    However, if you want to allow DML on the block it gets more complicated.

  • I have a VI and an attched .txt data file. Now I want to read the data from the .txt file and display it as an array in the front panel. But the result is not right. Any help?

    I have a VI and an attched .txt data file. Now I want to read the data from the .txt file and display it as an array in the front panel. But the result is not right. Any help?
    Attachments:
    try2.txt ‏2 KB
    read_array.vi ‏21 KB

    The problem is in the delimiters in your text file. By default, Read From Spreadsheet File.vi expects a tab delimited file. You can specify a delimiter (like a space), but Read From Spreadsheet File.vi has a problem with repeated delimiters: if you specify a single space as a delimiter and Read From Spreadsheet File.vi finds two spaces back-to-back, it stops reading that line. Your file (as I got it from your earlier post) is delimited by 4 spaces.
    Here are some of your choices to fix your problem.
    1. Change the source file to a tab delimited file. Your VI will then run as is.
    2. Change the source file to be delimited by a single space (rather than 4), then wire a string constant containing one space to the delimiter input of Read From Spreadsheet File.vi.
    3. Wire a string constant containing 4 spaces to the delimiter input of Read From Spreadsheet File.vi. Then your text file will run as is.
    Depending on where your text file comes from (see more comments below), I'd vote for choice 1: a tab delimited text file. It's the most common text output of spreadsheet programs.
    Comments for choices 1 and 2: Where does the text file come from? Is it automatically generated or manually generated? Will it be generated multiple times or just once? If it's manually generated or generated just once, you can use any text editor to change 4 spaces to a tab or to a single space. Note: if you want to change it to a tab delimited file, you can't enter a tab directly into a box in the search & replace dialog of many programs like notepad, but you can do a cut and paste. Before you start your search and replace (just in the text window of the editor), press tab. A tab character will be entered. Press Shift-LeftArrow (not Backspace) to highlight the tab character. Press Ctrl-X to cut the tab character. Start your search and replace (Ctrl-H in notepad in Windows 2000). Click into the Find What box. Enter four spaces. Click into the Replace With box. Press Ctrl-V to paste the tab character. And another thing: older versions of notepad don't have search and replace. Use any editor or word processor that does.

  • Hi I want to create a search form with drop down search criteria. This form should then search on the same site and display the search results. Is there HTML available for this? Or an oline site that I can use to build this form? I created a form in Jotfo

    Hi I want to create a search form with drop down search criteria. This form should then search on the same site and display the search results. Is there HTML available for this? Or an oline site that I can use to build this form? I created a form in Jotform.com, but this form doesn't search the site, instead it sends me an e-mail. Do you have a solution for me? Thanks.

    Hi I want to create a search form with drop down search criteria. This form should then search on the same site and display the search results. Is there HTML available for this? Or an oline site that I can use to build this form? I created a form in Jotform.com, but this form doesn't search the site, instead it sends me an e-mail. Do you have a solution for me? Thanks.

  • Where is the magnet located in the track pad and display lid?

    where is the magnet located in the track pad and display lid?
    have to see if theres a problem with the display magnet because when i close the lid, the sleep function does not work.
    am using a fridge magnet to move around the track pad to see if this will activate sleep mode. im begining to wonder if its worth just going with out the auto sleep mode and maybe try n get some money of what i paid for it (it was a refurb machine)

    as a guess, around the middle of trackpad, maybe half an inch moving from the lead edge towards the screen
    also, give it a few seconds to activate in any one spot - it's not instant

  • How to report print to the printer immediately and display the popup?

    Dear friends,
    I am running my report in background and displaying the confirm results on popup window and sending the results to printer,
    but now i want to send the results page to printer then  want to display the popup.
    i have writen my popup perform after printer perform only but its not working...when i am clossing the popup or came back from that popup then only the results sending to printer...
    How to report print to the printer immediately and display the popup?
    Thanks in advance
    Sridhar

    Hi Sudheer,
    I am using my print parameters like this :
        NEW-PAGE PRINT ON DESTINATION ws_printer
                             IMMEDIATELY 'X'
                             KEEP IN SPOOL 'X'
                             NEW LIST IDENTIFICATION 'X'
                             SAP COVER PAGE 'X'
                             ARCHIVE MODE '1'
                             LINE-COUNT 64
                             LINE-SIZE 170
                             NEW-SECTION
                             NO DIALOG.
    Then also its not printing immediatly.
    here one thing for displaying the popup i am using submit report(calling another report for popup purpose)
    before trigering the submit programe i need to print this.
    Thanks
    Sridhar.

  • JSP, DataWebBean: How to dynamically set the where clause of query and display record

    Hi,
    I am reposting this question as per suggestions made by Mr. Dwight.
    I have used ViewCurrentRecord web bean to display records from EMP table. I have to use the Dept_Id_FK from the current
    record of the EMP table to display corresponding records of Dept table. I have a view object called DeptView in my Business
    Components which selects all the records from the Dept table.
    How do I get the value of Dept_Id_FK and use it to display the required records of the Dept table?
    I tried to declare a variable and get the value of Dept_Id_FK but it did not work. My code is as follows:
    <%! String m_DeptId = null; %>
    <jsp:useBean id="RowViewer" class="oracle.jbo.html.databeans.ViewCurrentRecord" scope="request">
    <%
    RowViewer.initialize(pageContext, "EMPApp_EMP_EMPAppModule.EMPView1");
    RowViewer.setReleaseApplicationResources(false);
    RowViewer.getRowSet().next();
    m_DeptId = (String)RowViewer.getRowSet().getCurrentRow().getAttribute("DeptIdFk");
    %>
    </jsp:useBean>
    Thanks.
    null

    First of all, Thank you very much for making use of the new topic format. It is very much appreciated.
    As for your question, I think there are several different ways to accomplish what I think you want to do.
    1. Create a view object that includes both Emp and Dept entities and join them there. In this case, your query would look something like this:
    Select e.empno,e.name,...,d.dname,d.loc from emp e, dept d
    where e.deptno = d.deptno
    You should be able to create a JSP off of this view object that contains both the employee and department information. In this case, BC4J takes care of the foreign key to primary key coordination.
    2. In order to set a dynamic where clause for a view, you need to do the following in your usebean tag:
    rsn.initialize(application,session, request,response,out,"DeptView");
    rsn.getRowSet().getViewObject().setWhereClause("deptno=" &#0124; &#0124; m_DeptId);
    rsn.getRowSet().getViewObject().executeQuery();
    rsn.getRowSet().first();
    You will need to do this in a separate usebean tag from the EmpView, since the usebean can only initialize one view object.
    In other words, you would have your ViewCurrentRecord bean tag for the EmpView, then a separate one for the DeptView where you use the above code to set the where clause to display just the information for the department you want.
    Another option, but one I'm not sure would work as well, is to create a master-detail JSP to do this for you. Usually a master-detail is a one-to-many (one department to many employees). Your request appears to be the reverse, but might still be doable using the same mechanism.
    You set up relationships between views in your BC4J project using View Links. If you used the BC4J project wizard and created default views, some of these links may have been created for you. They are created when BC4J detects a foreign key to primary key relationship in the database.
    You can create your own View Links using the View Link wizard. Select your BC4J project node and choose Create View Link... from the context menu. You will be asked to select a source view (Emp), and a target view (Dept), then select the attribute in each view that related the two of them (deptno).
    Next, you need to reflect this new relationship setting in your application module. Select your app module and choose Edit from the context menu. On the data model page, select the EmpView node in the Selected list. Now select the DeptView node in the available list and shuttle it over. You should see DeptView1 via yourlink appear indented under the EmpView node. Save and rebuild your BC4J project to reflect the changes.
    In your JSP project, you can now have the wizard create a master-detail form for you based on DeptView1.
    Let me know if the above answers your question, or if I have misunderstood what it is you wanted to do.
    null

Maybe you are looking for