Find the date range of a employee

Hi all,
I have table with data like this
emp_id ename location from_date
===== ===== ===== =======
1001 SCOTT USA 01-Jan-2013
1001 SCOTT USA 30-Apr-2013
1001 SCOTT USA 16-May-2013
1001 SCOTT USA 30-Jun-2013
1001 SCOTT USA 19-Aug-2013
1001 SCOTT USA 03-Dec-2013
and the output like this(to_date's value will be generate from the query and the value will be the next row's value - 1 or the previous date of the next row)
emp_id ename location from_date to_date
===== ===== ===== ======= ======
1001 SCOTT USA 01-Jan-2013 29-Apr-2013
1001 SCOTT USA 30-Apr-2013 15-May-2013
1001 SCOTT USA 16-May-2013 29-Jun-2013
1001 SCOTT USA 30-Jun-2013 18-Aug-2013
1001 SCOTT USA 19-Aug-2013 02-Dec-2013
1001 SCOTT USA 03-Dec-2013 null/working

Hi,
It will not show you to_date for last row since we are taking values from from_date column. Look at the example below :-
SQL> select * from emp_test;
     EMPNO EMPTYPE                  SALARY JDATE         DEPTNO
         1 HR                        99999 04-NOV-08         10
         2 ADMIN                      1234 02-MAY-13         20
         3 IT                         4321 02-MAY-13         30
         4 OPERATION                  2314 02-MAY-13         40
         5 FINANCE                    9876 02-MAY-13         50
         5 FINANCE                   99999 02-MAY-13         50
6 rows selected.
SQL> select empno,emptype,salary,jdate,
  2           trunc(lead(jdate) over (order by jdate) -1) to_date
  3  from  emp_test;
     EMPNO EMPTYPE                  SALARY JDATE     TO_DATE
         1 HR                        99999 04-NOV-08 01-MAY-13
         2 ADMIN                      1234 02-MAY-13 01-MAY-13
         3 IT                         4321 02-MAY-13 01-MAY-13
         4 OPERATION                  2314 02-MAY-13 01-MAY-13
         5 FINANCE                    9876 02-MAY-13 01-MAY-13
         5 FINANCE                   99999 02-MAY-13
6 rows selected.
SQL>

Similar Messages

  • To check the date range

    Hi,
    I have a table that records the leave for employees. Like employee id , leave start date, leave end date and total hours. I need to find out , if the start date or end date was on weekend , or if the date range includes weekends . And there is one more table that stores public holidays. I also need to check if the leave start date or end date was on the public holiday or the range includes any public holidays.
    Thanks

    Hi,
    Assuming the time of day for all the dates involved is the same (e.g., if they are all TRUNCated DATEs, where the time is 00:00:00), that leave_start_date <= leave_end_date, and that the weekend consiists of Saturday and Sunday, you can do something like this:
    SELECT     leave_start_date
    ,     leave_end_date
    ,     CASE
             WHEN  TRUNC (leave_start_date, 'IW')     < TRUNC (leave_end_date + 2, 'IW')
             THEN  'Includes Saturday or Sunday'
             ELSE  'No weekend'
         END              AS weekend
    ,     CASE
             WHEN  EXISTS (
                              SELECT  1
                        FROM    holiday_table
                        WHERE   holiday_date BETWEEN m.leave_start_date
                                              AND       m.leave_end_date
             THEN  'Leave includes at least 1 holiday'
             ELSE  'No holidays'
         END          AS holiday
    FROM     leave_table     m
    ;This does not depend on your NLS settings.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for both tables, and also post the results you want from that data, as Andy requested.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.

  • How to find the Date and Time of Modification of Column in aTable?

    Hi all,
    Do  you know how to find the Date and Time of Addition of Column to a Particular Table?.
    I know however, How to find the modification time of the Table. Using the below Query :
    Select Object_Name, to_Char(Last_DDL_TIME, 'DD-Mon-YYYY HH24:MI:SS') Last_DDL from User_Objects where Object_Type = 'TABLE';
    Object_Name
    Last_DDL
    Employee
    20-Aug-2013 09:23:03
    I wanted to know the Creation or Modification Date and Timestamp of all columns of Employee Table?. Is it possible at all. If possible, How to get it?.
    Regards,
    Bhaskar M

    I agree with you on that. Since its a development enviornment I can remove the column but that not my point here.
    My whole purpose it to know whether we get the Column's Creation or Modification DateTime.

  • HT1414 how can i find the dates of the latest backup for iphone and ipad

    i cannot seem to find the dates of last  backup for my iphone or ipad..
    what buttons will lead me to the answer

    iTunes or iCloud?
    iTunes - in preferences > devices
    iCloud - from each device Settings > iCloud > Storage & Backup. The date last backed up will be below the Backup Now button.

  • Unable to find the data source in r/3  ECC 6.0 -  ( 0FI_GL_10 ) in RSA5

    Hi guys,
    I am unable to find the data source(0FI_GL_10) in RSA5.
    Presently I am using BI7.0 version with R/3 ECC 6.0.
    BI Patch level - 16.
    BI content Patch level - 8
    Thanks,
    Gupta

    Hi,
    Try Installing Application Component Hierarchies 
    http://help.sap.com/saphelp_nw2004s/helpdata/en/b3/c30a0e9c44204eb596c6353c827d2e/frameset.htm
    Use RSA9 for this.
    Hope this helps.
    Thanks,
    JituK

  • How do I find the date my MacMini was manufactured?

    It seems to me I used to know how to find the date of mfg for Mac computers under About This Mac. Is this still true?
    -Joe

    A quick way it to just enter your serial # at > Klantenservice: Serienummers
    Another is at > How to identify Mac mini models

  • How do I find the date of my last vault update?

    How do I find the date of my last vault update? All but one picture in a folder is missing from my library. I want to go back in Time Machine to the date/time of my last update to restore the lost images.

    Thanks, Frank. I was trying to make it too complicated, wasn't I

  • Creation of internal table dynamically based on the Date Range entered

    Hi SAPgurus,
    I have been facing one issue i.e creation of internal table dynamically based on the date range entered in the selection screen. For example the date range I am giving as 06/2006 to 08/2006, it should display the Fieldcatelog dynamically, this part i have completed but the only issue I am facing is to populate the sales data into that fields.
    Right now my program is displaying the ALV like this.
    Ex:
    <b>CSR    District   06/2006  07/2006  08/2006  totals</b>      
    Shiva      New York                             10.00
    Shiva      new york                             30.00
    Shiva      new york                             40.00
    but it should display like this
    <b>CSR    District 06/2006 07/2006 08/2006 totals</b>
    Shiva  New York  10.00   30.00 40.00
    80.00                 
    Please help me in this scenario, how to acheive like this..
    Thanks & Regards,
    Sivaram Kandula

    Hi Sivaram,
                 I also got the same requirement . i saw rich and your code whatever you have uploaded.i have created dynamic internal table but i am facing the issue to populating the data to my dynamic internal table.
    Sivaram, can you please explain your code after this.
    *<dyn_table>
    *tab_item.
      LOOP AT tab_item.
        ASSIGN COMPONENT 1 OF STRUCTURE <dyn_wa> TO <dyn_table>.
        ASSIGN COMPONENT 2 OF STRUCTURE <dyn_wa> TO <dyn_table>.
    *    <dyn_wa> = tab_item-bztxt.
    *    <dyn_wa> = tab_item-total.
    *    APPEND <dyn_wa> TO <dyn_table>.
    **    <dyn_wa> = tab_item-total.
    **    ASSIGN tab_item-bezei  TO <dyn_wa>.
    *  APPEND <dyn_table>.
      ENDLOOP.
    how you are puting the loop at tab_item. but tab_item is already commented.
    can you send me the code after that.
    i am sending some part of my code.
    CALL METHOD cl_alv_table_create=>create_dynamic_table
       EXPORTING
         it_fieldcatalog = gt_fCAT1
       IMPORTING
         ep_table        = new_table.
    ASSIGN new_table->* TO <dyn_table>.
       create data new_line like line of <dyn_table>.
       assign new_line->* to <dyn_wa>.
    select vbeln
            fkart
            vkorg
            vtweg
            fkdat
            spart
            fksto
            from vbrk
            client specified
            into table gt_vbrk
            where mandt = sy-mandt
            and fkart in ('ZF5','ZFR')
            and vkorg = '1100'
            and vtweg = '20'
            and fkdat in s_fkdat
            and spart = '06'
            and fksto = ' '.
       if gt_vbrk[] is not initial.
      select  vbeln
              fkimg
              prsdt
              netwr
              matnr
              arktx
              werks
              mwsbp
              from vbrp
              client specified
              into table gt_vbrp
              for all entries in gt_vbrk
              where vbeln = gt_vbrk-vbeln
              and werks in s_werks
              and matnr in s_matnr.
      endif.
    select mnr ltx spras from t247
    into table it_t247
    where spras = 'E'.
    data: lv_month1 type vbrp-prsdt,
           name1(3) type c,
           s_month type string,
            s_month1 type string,
             s_month2 type string.
    *      lv_netwr1 type vbrp-netwr,
    *          lv_mwsbp1 type vbrp-mwsbp.
          loop at gt_vbrp into gs_vbrp.
            gs_final2-matnr = gs_vbrp-matnr.
            gs_final2-arktx = gs_vbrp-arktx.
            gs_final2-fkimg = gs_vbrp-fkimg.
           lv_month1 = gs_vbrp-prsdt.
            read table it_t247 into wa_t247 with key mnr = lv_month1+4(2).
            if sy-subrc eq 0.
            name1 =  wa_t247-ltx.
            endif.
             concatenate  name1
                       lv_month1(4) into s_month SEPARATED BY '_' .
             CONCATENATE S_MONTH 'QTY' INTO S_MONTH1 SEPARATED BY ''.
              CONCATENATE S_MONTH 'VALUE' INTO S_MONTH2 SEPARATED BY ''.
             gs_final2-month = s_month.
              lv_netwr1 = gs_vbrp-netwr.
            lv_mwsbp1 = gs_vbrp-mwsbp.
            gs_final2-MONTH_QTY = S_MONTH1.
            GS_FINAL2-MONTH_VAL = S_MONTH2.
            gs_final2-value = lv_netwr1 + lv_mwsbp1.
           append gs_final2 to gt_final2.
           clear: gs_final2. "lv_name2.
           endloop.
           if gt_final2[] is not initial.
             sort gt_final2 by matnr month ascending .
             loop at gt_final2 into gs_final2.
            gs_final2_01 = gs_final2.
         collect gs_final2_01 into gt_final2_01.
        endloop.
           endif.
       ENDIF..
    Regards
    Ankur

  • How to find the data loaded from r/3 to bw

    hi
    how to find the data loaded from r/3 to bw is correct . i am not able to find which feild in the query is connected to which feild in the r/3 . where i am geting the data from r/3 . is there any process to find which feild  and table the data is comming from . plz help
    thanks in advance to u all

    Hi Veda ... the mapping between R/3 fields and BW InfoObjects should take place in Transfer Rules. Other transformation could take place in Update Rule.
    So you could proceed this way: look at InfoProvider Data Model and see if the Query does perform any calculation (even with Virtual keyfigures / chars). Than go back to Update Rules and search for other calculation / transformation. At least there are Tranfer Rule and eventually DataSource / Extraction Enhancements.
    As you can easily get there are many points where you have to look for ... it's a quite complex work but very usefull.
    Once you will have identified all mappings / transfromation see if BW data matchs R/3 (considering calculations ...)
    Good job
    GFV

  • How to find the Data Type of a column

    Dear All,
    How to find the Data Type of a Column dynamically in oracle Form.
    Thanks and Regards,
    Fazil
    Edited by: user11334489 on Aug 25, 2012 9:06 PM

    hi,
    you can use get_item_property built-in
    eg:
    declare
       l_item VARCHAR2(10);
    begin
       l_item := Get_Item_Property('item_name',DATATYPE);
    end;

  • I'm moving an internal hard drive from an old computer to a new computer.  How do I transfer the catalog data to my new computer so the Organizer of Photoshop Elements 6 will find the data on the hard that has been moved to the new computer?

    I'm moving an internal hard drive from an old computer to a new computer.  (My new compute runs Windows 8.1) How do I transfer the catalog data to my new computer so the Organizer of Photoshop Elements 6 will find the data on the hard that has been moved to the new computer?  Is this possible or do I have to use the procedure of copying the catalog along with the photos to a back up hard drive and then restore them on the new computer?

    The 'normal' procedure is to do a PSE organizer backup (not a copy or a backup from external tools) to an external drive, then a restore to the new location.
    The advantage is that you have a backup of both catalog and media files and you don't have all disconnected files, which would happen with external backup tools. Also, if you restore with a more recent elements version, the catalog will be automatically updated to the new format.
    The drawback in your situation is that you'll have either to overwrite all your files or restore to a custom location, creating a duplicate photo library (which supposes you have enough free space).
    It would be possible to simply use the organizer in the old PC to move the catalog to a new 'custom' folder just under your C: root drive. The catalog would be accessible once the drive will be installed in the new PC. Then you would have all files 'disconnected' due to the fact that all your media files are now on a drive with a different letter. Reconnecting a whole library is a hard job with PSE6, less so with PSE11/PSE12.
    If the idea of fiddling with the sqlite database with external sqlite manager tools is ok for you, I can describe the process more in detail. You only copy your catalog folder (as suggested above) to another location. Instead of trying the 'reconnection' way, you install the sqlite utility on the new computer. When the old drive is installed in the new computer, you simply edit a given record in the catalog database, catalog.psedb, and start the organizer with your copied catalog by simply double clicking the 'catalog.psedb' file.
    Even if the last solution is much, much quicker, I would still create a new PSE backup : you have never too much safety .

  • To find the date type fields in the row and validate those date fields

    TYPES : BEGIN OF TY_MARA,
              MATNR TYPE MARA-MATNR,
              ERSDA TYPE MARA-ERSDA,
              ERNAM TYPE MARA-ERNAM,
              LAEDA TYPE MARA-LAEDA,
              MTART TYPE MARA-MTART,
            END OF TY_MARA.
    DATA : it_mara TYPE STANDARD TABLE OF ty_mara,
          it_mara1 TYPE STANDARD TABLE OF ty_mara,
           wa_mara TYPE ty_mara.
    loop at it_mara into wa_mara.
      describe field wa_mara-ersda type c_data.
    if c_data eq 'D'.
      CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
        EXPORTING
          date                            = wa_mara-ersda
       EXCEPTIONS
         PLAUSIBILITY_CHECK_FAILED       = 1
         OTHERS                          = 2
      IF sy-subrc eq 0.
    wa_mara-ersda = '00000000'.
        append wa_mara to it_mara1.
        write :wa_mara-matnr,wa_mara-ersda.
        else.
            wa_mara-ersda = '00000000'.
        append wa_mara to it_mara1.
        write :wa_mara-matnr,wa_mara-ersda.
      ENDIF.
      endif.
      endloop.
    This issue regarding how to find the date type fields in the row and validate those date fields.If its not a valid date ,i have to assign initial value to that.
    I've tried that for single field using describe field.Please help me do that for all fields.

    Hi Sam,
     I believe we had discussed the same issue in the below thread. Can you please refer the below one?
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/d93e16ff-c123-4b36-b60b-60ccd34f6ca7/calculate-time-differences-in-infopath?forum=sharepointcustomizationprevious
    If it's not helping you please let us know
    Sekar - Our life is short, so help others to grow
    Whenever you see a reply and if you think is helpful, click "Vote As Helpful"! And whenever
    you see a reply being an answer to the question of the thread, click "Mark As Answer

  • How do I find the date and time stamp on pictures?

    How do I find the date and time stamp for my pictures?

    The Photos app will not do this but other apps will. iPhoto has an icon that when tapped with the photo open will show the EXIF information you are looking for. iPhoto is not free but you can purchase it in the App Store.
    There may be other photo apps that provide this information as well.
    PhotoForge2 will show the EXIF data as well as the GPS data if it is available.

  • HT5527 I HAVE OLD PHONES BACKED UP.  how do i find the data and recover or delete dups and junk

    I HAVE OLD iPHONES BACKED UP.  how do i find the data and recover or delete dups and junk

    You can't see the data inside the backup, and you can't restore just part of the data if that's what you're asking. To see the data you have to restore the entire backup.

  • Can I use SYSDATE in the WHERE clause to limit the date range of a query

    Hi,
    Basicaly the subject title(Can I use SYSDATE in the WHERE clause to limit the date range of a query) is my question.
    Is this possible and if it is how can I use it. Do I need to join the table to DUAL?
    Thanks in advance.
    Stelios

    As previous poster said, no data is null value, no value. If you want something, you have nvl function to replace null value by an other more significative value in your query.<br>
    <br>
    Nicolas.

Maybe you are looking for