Need help in query to display dates as start, end dates

Hi,
I am trying the following output from the below table structure, data
StartDAte Endate Reason          duration
12-02-09 12:00:00 12-02-09 13:10:20 planned activity 1:10:20
01-04-09 08:30:34 01-04-09 15:00:20 planned activity 6:30:34
12-04-09 17:10:45 12-04-09 17:11:04 unplanned activity 0.10
23-05-09 22:00:11 23:05-09 22:15:09 planned activity 0.15
Mdate Reason omode host
12-02-09 12:00:00 planned activity st 366
12-02-09 13:10:20 planned activity ed 366
01-04-09 08:30:34 planned activity st 366
01-04-09 15:00:20 planned activity ed 366
12-04-09 17:10:45 unplanned activity st 366
12-04-09 17:11:04 unplanned activity ed 366
23-05-09 22:00:11 planned activity st 366
23:05-09 22:15:09 planned activity ed 366
i tried with individual query but not able to get the output in combined way of start, end dates together with calculation of time difference, i tried using case options but not successful in resolve it.
select to_char(mdate,'dd-mm-yyyyy hh24:mi:ss')startdate, reason
from date_md where omode like 'st'
order by o_char(mdate,'dd-mm-yyyyy hh24:mi:ss')startdate;
select to_char(mdate,'dd-mm-yyyyy hh24:mi:ss')enddate, reason
from date_md where omode like 'ed'
order by o_char(mdate,'dd-mm-yyyyy hh24:mi:ss')enddate;
any suggestions on type of query should be used is welcomed.

Or maybe
SQL>  WITH t AS (SELECT TO_DATE ('12-02-09 12:00:00',
                           'DD-MM-YY HH24:MI:SS')
                   event_date,
                  'planned activity' activity,
                  'st' start_end,
                  366 HOST
           FROM DUAL
           UNION ALL
           SELECT TO_DATE ('12-02-09 13:10:20',
                           'DD-MM-YY HH24:MI:SS'),
                  'planned activity',
                  'ed',
                  366
           FROM DUAL
           UNION ALL
           SELECT TO_DATE ('01-04-09 08:30:34',
                           'DD-MM-YY HH24:MI:SS'),
                  'planned activity',
                  'st',
                  366
           FROM DUAL
           UNION ALL
           SELECT TO_DATE ('01-04-09 15:00:20',
                           'DD-MM-YY HH24:MI:SS'),
                  'planned activity',
                  'ed',
                  366
           FROM DUAL
           UNION ALL
           SELECT TO_DATE ('12-04-09 17:10:45',
                           'DD-MM-YY HH24:MI:SS'),
                  'unplanned activity',
                  'st',
                  366
           FROM DUAL
           UNION ALL
           SELECT TO_DATE ('12-04-09 17:11:04',
                           'DD-MM-YY HH24:MI:SS'),
                  'unplanned activity',
                  'ed',
                  366
           FROM DUAL
           UNION ALL
           SELECT TO_DATE ('23-05-09 22:00:11',
                           'DD-MM-YY HH24:MI:SS'),
                  'planned activity',
                  'st',
                  366
           FROM DUAL
           UNION ALL
           SELECT TO_DATE ('23-05-09 22:15:09',
                           'DD-MM-YY HH24:MI:SS'),
                  'planned activity',
                  'ed',
                  366
           FROM DUAL)
SELECT MIN (event_date) startdate,
       MAX (event_date) enddate,
       MAX (activity) reason,
       NUMTODSINTERVAL (MAX (event_date) - MIN (event_date),
                        'day')
        duration
FROM t
GROUP BY TRUNC (event_date)
STARTDATE             ENDDATE               REASON             DURATION                                         
23.05.2009 22:00:11   23.05.2009 22:15:09   planned activity   +00 00:14:57.999999                              
12.02.2009 12:00:00   12.02.2009 13:10:20   planned activity   +00 01:10:19.999999                              
01.04.2009 08:30:34   01.04.2009 15:00:20   planned activity   +00 06:29:45.999999                              
12.04.2009 17:10:45   12.04.2009 17:11:04   unplanned activity +00 00:00:18.999999                              
4 rows selected.

Similar Messages

  • Need help in query to display lot and serial numbers for a Wip Job Component

    Hi ALL,
    I have a requirement as below.
    I need to display lot and serial numbers for a Wip Job Component, i have a xml report in that for each wip job component i need to check whether it is a lot control item or serial control item based on that i need to display some data. so can you please help me to get the query to indentify the lot and serial number for a wip job component.
    Thanks

    Thank you for replying Gordon.  I did not remember I had asked this before.  I no longer have access to the other account. 
    What I need on the query is that I want  a list of items with the on order quantity and when we are expecting this order to be received.  The receiving date is based on the PO delivery date.  The trick here is that  I need to Master sku to show the delivery date of the component sku.  In my scenario all components have the same delivery date for the Master sku.  If there are mulitple delivery dates because each warehouse is getting them on a different date then I want to get the delivery date for that warehouse.
    Let me know if this is possible and if yes please guide towards a query for it.
    Thank you.

  • Need Help to query Lync Database for User Information

    Need Help to Query the lync database to retrieve below user information.
    1. SIP Address of the registered user
            2. Phone Number configured to the particular account.
            3. IP Address
           4. Last Logged in time.
    I am trying to pull the above information from rtc database for all the registered users. Please let me know if this is possible and it would be great if you can throw some light on what tables to look for the data. Thank You.

    Hi,
    For SIP address and Phone number you can check RTC database.
    IP Address:
    You can refer to the link below to query IP address: 
    http://h30499.www3.hp.com/t5/Business-Service-Management-BAC/Monitoring-Lync-with-the-User-Registrations-Viewer-Free-NMC-tool/ba-p/5961497#.UtOU43mIrwo
    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.
    Please make sure that you completely understand the risk before retrieving any suggestions from the above link.
    Last Logged in time:
    You can refer to the link below:
    http://blogs.technet.com/b/dodeitte/archive/2011/05/11/how-to-get-the-last-time-a-user-registered-with-a-front-end.aspx
    Best Regards,
    Eason Huang
    Eason Huang
    TechNet Community Support

  • How do you use the "Item Containing Start/End Date" in a Calendar?

    Hi
    I want to do a calendar where the days shown will be conditional to a certain interval. Now I though I could achieve that using the Item Containing Start Date of a calendar. But it doesn't seem to work. In the help it says :
    Enter an item in the application which holds the start date of the calendar. The format of the date in this item must be YYYYMMDD.
    This is what I did here
    http://apex.oracle.com/pls/otn/f?p=34530:1::::::
    I have 3 fields. 2 for the Start Date and End Date and 1 for the "Date Item" parameter. Only the latter has an effect on the calendar display, the calendar only displays the month of the "Date Item" (in monthly mode).
    Wether or not I check "Begin at Start of Interval", it doesn't affect the way those fields are affecting the Calendar.
    So, how do we use that "Item Containing Start/End Date" parameter?

    Hello,
    does yout Script work when you begin with ?:
    Start-Process powershell -Verb runAs
    Best regards,
    Stefan
    German Orchestrator Portal ,
    My blog in English

  • Actual Start Date vs Actual End Date - Activity

    In an Activity, I would like to seperately enter the Actual Start Date and Actual End Date.
    - If I try this using (partial) confirmation,  I receive a pop-up with an error that the two dates must be entered together or no dates can be entered.
    The activity in my project can take over a year to complete and the requirement is to confirm start (at start) and to confirm end (at end).
    Does anyone know of a solution for this issue?
    Thanks in advance!

    Hi Patrick,
    I think you need to research a bit more on confirmations in PS. Actual dates in partial confirmations are practically interpreted as provisional actual start dates and actual finish dates. The actual start for the activity remains the same however the actual finish date is overwritten once the final confirmation is entered.
    For example, take an activity with start date 05.09.2011 and finish date as 14.09.2011. Now when you provide confirmations on a daily basis, you can use the following strategy:
    Day 1, 05.09.2011: actual start 05.09.2011, actual finish 05.09.2011, % complete 10%
    Day 1, 06.09.2011: actual start 05.09.2011, actual finish 06.09.2011, % complete 20%
    Day 1, 07.09.2011: actual start 05.09.2011, actual finish 07.09.2011, % complete 25%
    Only when you provide the final confirmation the actual finish date is confirmed. The various confirmation line items may be viewed via CN48N.
    Regards,
    Ammar

  • Unable to found Bucket start date and bucket end date in OFSAA 6

    Hi,
    How to find the Bucket start date and bucket end date in OFSAA 6.
    I found following tables to mapped to Dim_Result_Bucket but  unable to found columns pointing to Bucket Start Date and Bucket End Date.
    Tables:
    fsi_income_simulation_buckets
    fsi_process_run_history
    fsi_time_bucket_master
    fsi_lr_irr_buckets_aux
    fsi_m_alm_process
    Kindly let me know the solution.

    Hi;
    Please check below link which could be helpful for your issue:
    https://blogs.oracle.com/ebs/entry/service_contracts_warranty_created_by
    Regard
    Helios

  • Select Records between Begin Date/Time and End Date/Time

    Hi, I need to select records from table GLPCA where the CPUDT and CPUTM are between a START DATE/TIME and END DATE/TIME. 
    I have the below logic from an SAP Solution, but it doesn't seem to be working right in my opinion.  It is picking up records earlier than the date ranges.  Can anyone tell me how I might be able to accomplish this?  I'm hoping this is an easy one for the ABAPPERs... 
    Thanks,
    START DATE 20091022
    START TIME 125736
    END DATE 20091022
    END TIME 135044
    CPUDT 20091022
    CPUTM 100257
          SELECT * FROM GLPCA
             WHERE ( CPUDT >= STARTDATE AND ( CPUTM >= STARTTIME OR ( CPUDT <= ENDDATE AND CPUTM <= ENDTIME ) ) ).

    Thank you all!  I ended up using the following:
    SELECT * FROM GLPCA
              WHERE RYEAR IN L_R_RYEAR
                AND ( ( CPUDT = STARTDATE AND CPUTM >= STARTTIME ) OR CPUDT > STARTDATE )
                AND ( ( CPUDT = ENDDATE   AND CPUTM <= ENDTIME )   OR CPUDT < ENDDATE ).
    This child was born from the following thread that was found:
    update date and time of client record

  • Fixed start date and variable end date

    I'm using Project 2010 Standard. Task A has already started. It can't end until 2 weeks after the completion of task B. The only way I can make Project schedule this task is by doing so manually, allowing Project to calculate the duration. But then if the
    end date of task B changes, Project reschedules the entire task based on the duration without regard for the start date. If I add a % complete to task A, then the end date doesn't change if the end date of task B does. Project seems to fix the duration
    once it's calculated. I need the duration to be flexible based on the fixed start date and the end date of task B. This project file is stored in SharePoint so I can't make task A a hammock task. I get the error "You cannot create links from a project
    file that exists on a Web folder to another file" even though it's the same file. Any suggestions would be greatly appreciated.

    WhoKnows,
    I'm afraid without a hammock task the only way to do what you want is either with a manual reschedule or a macro to recalculate the duration of Task A when Task B moves.
    Update: Okay, after playing around here is a little trick that might work.
    1. Break Task A into two parts (e.g. -1 and -2)
    2. Set the predecessor of Task A-2 to be finish-to-start with Task A-1 and finish-to-finish + 2w with Task B
    Depending on the nature of Task A you may still need to do a little manual adjusting but it will effectively allow the start of Task A to be fixed and the finish to be variable depending on the status of Task B. Does that work for you?
    John

  • Start/End dates for cProjects

    Hi,
    While creating a Project in PS, if the Start/ End date of the project is a weekend or holiday, the start of the cProject shifts to a working day u2013 is there a config to set this to take the actual date (working or holiday). Waiting for your reply @ earliest.
    Thanks & Regards,
    Gaurav

    Hi Gaurav,
    this shifting of the dates is likely a "feature" of the scheduling process. As soon as a calendar has been maintained for the objects the weekends are taken into account and the dates determined for the object being subject of scheduling and it is enforced that the dates are working days.
    To answer your question, if you maintained a calendar without weekends and public holidays - or no calendar at all - this shift won't occur.
    Hoping this helps...
    Best regards,
    Thomas

  • PARAMETER_EXCEPTION: Start date is after end date

    WORKLOAD ANALYSIS (PORTAL ACTIVITY REPORTING) : PARAMETER_EXCEPTION: Start date is after end date.
    Hello,
    We get the above exception when we analyzed the extractor framework logs for EP Workload analysis extractor.
    Can someone please advice.
    Thanks
    Srikanth M

    Hi Nacho,
      Could you please check if the Solution Manager time format for the user used for the Workload analysis is same as that of the monitored system. This error was caused in our landscape as the format in the monitored system was having a dd.mm.yyyy and that of the user in solman was mm.dd.yyyy. You can check the same in the transaction SU01 --> Change/Display --> Defaults tab --> Date format.
    Thanks,
    Lijin Xavier

  • Planning attributes in 11.1.2.2 and start/end dates in a cell

    Hi. In Planning 11.1.2.2., can I make use of attribute dimensions as I would in a BSO Essbase cube?
    Also can I enter a start date and an end date entry in two different account members (e.g., start_date and end_date)?
    Thanks

    Hi,
    Yes, I believe you can use it.
    And you can change the Account member Data type as Date. Then use these Accounts in the Planning Web Form. Form will give you facility to select the Date...
    VB..

  • Alternate Greetings - start/end dates

    We have Unity Connection 8.6. I know alternate greetings can have end dates, but our users really want start dates also. Is this possible? I have not seen it mentioned anywhere, but I thought I would check before giving up on it.

    Hi
    +5 for Mr/Chris . Only  Enabled until "end dates" or no end date  avilable on CUC, nothing related to start date.
    http://www.cisco.com/en/US/docs/voice_ip_comm/connection/7x/user/guide/assistant/7xcucugasst080.html
    Thanks
    please rate all useful infromation

  • Need help in query to have all items in sap with PO data on order, date

    Hello Everyone,
    I need some help in writing a query to show all items in sap db to have itemcode, itemname, onhand, sellable(onhand-committed), on order, and the delivery date when that time should be received.  I need to know what items are regular items, which ones are master and components.  For the master I need to have the deliver date of the PO for the component.
    I have written this.
    SELECT DISTINCT TOP (100) PERCENT T1.ItemCode, SUM(T1.Sellable) AS Sellable, T1.OnOrder, MAX(T1.Docduedate) AS DeliveryDate, T1.WhsCode
    FROM         (SELECT     ItemCode, Sellable, OnOrder, '1/1/1900' AS Docduedate, WhsCode
                           FROM          dbo.V_RAZ_StoreInv
                           UNION ALL
                           SELECT     TOP (100) PERCENT ItemCode, '0' AS Sellable, Quantity AS Onorder, DocDueDate, WhsCode
                           FROM         dbo.V_RAZ_OPENPOSDATA
                           ORDER BY ItemCode) AS T1 LEFT OUTER JOIN
                          dbo.V_RAZ_ItemInfo ON T1.ItemCode = dbo.V_RAZ_ItemInfo.ItemCode
    GROUP BY T1.ItemCode, T1.OnOrder, T1.WhsCode, dbo.V_RAZ_ItemInfo.OnHold
    HAVING      (dbo.V_RAZ_ItemInfo.OnHold = 'n')
    ORDER BY T1.ItemCode, T1.WhsCode
    and for the v_raz_openposdata I have the following query
    SELECT     dbo.OPOR.DocNum, dbo.OPOR.DocStatus, dbo.POR1.WhsCode, dbo.POR1.ItemCode, dbo.POR1.Dscription, dbo.POR1.Quantity, dbo.POR1.OpenQty,
                          dbo.POR1.LineStatus, dbo.OPOR.DocDueDate
    FROM         dbo.OPOR LEFT OUTER JOIN
                          dbo.POR1 ON dbo.OPOR.DocEntry = dbo.POR1.DocEntry
    WHERE     (dbo.OPOR.DocStatus = 'O')
    Any help is greatly appreciated. 
    Right now I do get the delivery date for regular items and components but the master sku for the component all of them have 1/1/1900. 
    Thank you

    Thank you for replying Gordon.  I did not remember I had asked this before.  I no longer have access to the other account. 
    What I need on the query is that I want  a list of items with the on order quantity and when we are expecting this order to be received.  The receiving date is based on the PO delivery date.  The trick here is that  I need to Master sku to show the delivery date of the component sku.  In my scenario all components have the same delivery date for the Master sku.  If there are mulitple delivery dates because each warehouse is getting them on a different date then I want to get the delivery date for that warehouse.
    Let me know if this is possible and if yes please guide towards a query for it.
    Thank you.

  • Need help with SQL retrieval for previous month till current date

    Hi ,
    Need help generating statistics from previous month from date of enquiry till current date of enquiry.
    and have to display it according to date.
    Date of enquiry : 03/02/2012
    Application Type| 01/01/2012 | 02/01/2012 | 03/01/2012 |...... | 31/01/2012 | 01/02/2012 | 02/02/2012 | 03/02/2012 |
    sample1 20 30 40
    sample 2 40 40 50
    sample 3 50 30 30
    Hope you guys can help me with this.
    Regards

    Hi,
    932472 wrote:
    Scenario
    1)If i run the query at 12 pm on 03/2/2012. the result i will have to display till the current day.
    2)displaying the count of the application made based on the date.
    Application type 01012012 | 02012012 | 03012012 | ..... 01022012| 02022012|03022012
    sample 1 30 40 50 44 30
    sample 2 35 45 55
    sample 3 36 45 55Explain how you get those results from the sample data you posted.
    It would help a lot if you posted the results in \ tags, as described in the forum FAQ. {message{id=9360002}
    SELECT     application_type as Application_type
    ,     COUNT (CASE WHEN created_dt = sysdate-3 THEN 1 END)     AS 01012012 (should be getting dynamically)
    ,     COUNT (CASE WHEN created_dt = sysdate-4 THEN 1 END)     AS 02022012
    ,     COUNT (CASE WHEN created_dt = sysdate-5 THEN 1 END)     AS 03022012
    , COUNT (CASE WHEN created_dt = sysdate-6 THEN 1 END)     AS 04022012
    FROM     table_1
    GROUP BY application_type
    ORDER BY     application_typeThat's the bais idea.
    You can simplify it a little by factoring out the date differences:WITH got_d     AS
         SELECT     qty
         ,     TRUNC ( dt
              - ADD_MONTHS ( TRUNC (SYSDATE, 'MON')
                        , -1
              ) AS d
         FROM table1
         WHERE     dt     >= ADD_MONTHS ( TRUNC (SYSDATE, 'MON')
                        , -1
         AND dt     < TRUNC (SYSDATE) + 1
    SELECT     SUM (CASE WHEN d = 1 THEN qty END)     AS day_1
    ,     SUM (CASE WHEN d = 2 THEN qty END)     AS day_2
    ,     SUM (CASE WHEN d = 62 THEN qty END)     AS day_62
    FROM     got_d
    See the links I mentioned earlier for getting exactly the right number of columns, and dynamic column aliases.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Need help with query joining several tables into a single return line

    what i have:
    tableA:
    puid, task
    id0, task0
    id1, task1
    id2, task2
    tableB:
    puid, seq, state
    id0, 0, foo
    id0, 1, bar
    id0, 2, me
    id1, 0, foo
    id2, 0, foo
    id2, 1, bar
    tableC:
    puid, seq, date
    id0, 0, 12/21
    id0, 1, 12/22
    id0, 2, 12/22
    id1, 0, 12/23
    id2, 0, 12/22
    id2, 1, 12/23
    what i'd like to return:
    id0, task0, 12/21, 12/22, 12/22
    id1, task1, 12/23, N/A, N/A
    id2, task2, 12/22, 12/23, N/A
    N/A doesn't mean return the string "N/A"... it just means there was no value, so we don't need anything in this column (null?)
    i can get output like below through several joins, however i was hoping to condense each "id" into a single line...
    id0, task0, 12/21
    id0, task0, 12/22
    id0, task0, 12/23
    id1, task1, 12/23
    is this possible fairly easily?
    Edited by: user9979830 on Mar 29, 2011 10:53 AM
    Edited by: user9979830 on Mar 29, 2011 10:58 AM

    Hi,
    Welcome to the forum!
    user9979830 wrote:
    what i have:...Thanks for posting that so clearly!
    Whenever you have a question, it's even better if you post CREATE TABLE and INSERT statements for your sample data, like this:
    CREATE TABLE     tablea
    (       puid     VARCHAR2 (5)
    ,     task     VARCHAR2 (5)
    INSERT INTO tablea (puid, task) VALUES ('id0',  'task0');
    INSERT INTO tablea (puid, task) VALUES ('id1',  'task1');
    INSERT INTO tablea (puid, task) VALUES ('id2',  'task2');
    CREATE TABLE     tablec
    (       puid     VARCHAR2 (5)
    ,     seq     NUMBER (3)
    ,     dt     DATE          -- DATE is not a good column name
    INSERT INTO tablec (puid, seq, dt) VALUES ('id0',  0,  DATE '2010-12-21');
    INSERT INTO tablec (puid, seq, dt) VALUES ('id0',  1,  DATE '2010-12-22');
    INSERT INTO tablec (puid, seq, dt) VALUES ('id0',  2,  DATE '2010-12-22');
    INSERT INTO tablec (puid, seq, dt) VALUES ('id1',  0,  DATE '2010-12-23');
    INSERT INTO tablec (puid, seq, dt) VALUES ('id2',  0,  DATE '2010-12-22');
    INSERT INTO tablec (puid, seq, dt) VALUES ('id2',  1,  DATE '2010-12-23');This way, people can re-create the problem and test their ideas.
    It doesn't look like tableb plays any role in this problem, so I didn't post it.
    Explain how you get the results from that data. For example, why do you want this row in the results:
    PUID  TASK  DT1        DT2        DT3
    id0   task0 12/21/2010 12/22/2010 12/22/2010rather than, say
    PUID  TASK  DT1        DT2        DT3
    id0   task0 12/22/2010 12/21/2010 12/22/2010? Does 12/21 have to go in the first column because it is the earliest date, or is it because 12/21 is related to the lowest seq value? Or do you even care about the order, just as long as all 3 dates are shown?
    Always say what version of Oracle you're uisng. The query below will work in Oracle 9 (and up), but starting in Oracle 11, the SELECT ... PIVOT feature could help you.
    i can get output like below through several joins, however i was hoping to condense each "id" into a single line... Condensing the output, so that there's only one line for each puid, sounds like a job for "GROUP BY puid":
    WITH     got_r_num     AS
         SELECT     puid
         ,     dt
         ,     ROW_NUMBER () OVER ( PARTITION BY  puid
                                   ORDER BY          seq          -- and/or dt
                           )         AS r_num
         FROM    tablec
    --     WHERE     ...     -- If you need any filtering, put it here
    SELECT       a.puid
    ,       a.task
    ,       MIN (CASE WHEN r.r_num = 1 THEN r.dt END)     AS dt1
    ,       MIN (CASE WHEN r.r_num = 2 THEN r.dt END)     AS dt2
    ,       MIN (CASE WHEN r.r_num = 3 THEN r.dt END)     AS dt3
    ,       MIN (CASE WHEN r.r_num = 4 THEN r.dt END)     AS dt4
    FROM       tablea    a
    JOIN       got_r_num r  ON   a.puid  = r.puid
    GROUP BY  a.puid
    ,            a.task
    ORDER BY  a.puid
    ;I'm guessing that you want the dates arranged by seq; that is, for each puid, the date related to the lowest seq comes first, regardless of whther that date is the earliest date for that puid or not. If that's not what you need, then change the analytic ORDER BY clause.
    This does not assume that the seq values are always consecutive integers (0, 1, 2, ...) for each puid. You can skip, or even duplicate values. However, if the values are always consecutive integers, starting from 0, then you could simplify this. You won't need a sub-query at all; just use seq instead of r_num in the main query.
    Here's the output I got from the query above:
    PUID  TASK  DT1        DT2        DT3        DT4
    id0   task0 12/21/2010 12/22/2010 12/22/2010
    id1   task1 12/23/2010
    id2   task2 12/22/2010 12/23/2010As posted, the query will display the first 4 dts for each puid.
    If there are fewer than 4 dts for a puid, the query will still work. It will leave some columns NULL at the end.
    If there are more than 4 dts for a puid, the query will still work. It will display the first 4, and ignore the others.
    There's nothing special about the number 4; you could make it 3, or 5, or 35, but whatever number you choose, you have to hard-code that many columns into the query, and always get that many columns of output.
    For various ways to deal with a variable number of pivoted coolumns, see the following thread:
    PL/SQL
    This question actually doesn't have anything to do with SQL*Plus; it's strictly a SQL question, and SQL questions are best posted on the "SQL and PL/SQL" forum:
    PL/SQL
    If you're not sure whether a question is more of a SQL question or a SQL*Plus question, then post it on the SQL forum. Many more people pay attention to that forum than to this one.

Maybe you are looking for

  • NW2004s: Assigning a custom theme to a web dynpro running in the portal

    The situation is as follows: Some web-dynpros (for java) have a custom theme, a theme which is <b>not</b> the default theme of the portal or  the default theme for web-dynpros in general. In NW2004 this worked as follows: When starting a web-dynpro i

  • Ship to party PO number line item field updating in ORDERS IDOC

    Hi Experts,          We are in the process of creating the Sales order by receiving EDI data from customer and converting in to IDOC format and trying to create the sales order. While executing the ORDERS IDOC message type sales order is getting crea

  • Displayport to ADC?

    Can I use the displayport to dvi and then plug that in to my old DVI to ADC adaptor and plug in my old (but still working!) 17 inch display?

  • Jpeg Image file size for a Downloadable Product

    I'm creating a site in BC for the client to sell digital download copies of their original photographs. The purpose of the product for the consumer would be to use the low res download as a screen save or for viewing in a gallery on a desktop, tablet

  • Without Distrubing Existing mapping

    Hi Experts, I have a small doubt can you clarify it plzz urgent!!!!!... In Designer one project name is combineddatastore( using dataserver: useredwprod.cds, PS:useredwprod.cdsdefault, LS: CDS), in this all mapping are there everything is working fin