How to find login times greater than 24 hours from custom table.

Hello Guru's,
I am having trouble approaching how to construct a query that will find who has been logged in for more than 24 hours, this table is updated every few hours to show who's logged in and where- I am attempting to find out if someone has been logged in for more than 24 hours- if so, who and where. This is difficult for me because I need to compare each recorded for each user login and then see if the next entry is greater than 24 hours from the previous entry.
A table holds the login times and locations as table position_hist:
position_id,userid,upd_date.
Something like;
select position_id,userid,upd_date from position_hist where (select upd_date from position_hist where "the next entry for that user and that position is greater than 24 hours?????"
I guess the easier way to look at it is for a given position_id who has been logged in for more than 24 hours in one go.
Any advice would be brilliant :-)

It's hard without knowing your Oracle version, or having any sample data to work with. Please post that in the future using \ tags and DDL/DML.
Here is what I came up with as a guess:SQL> WITH POSITION_HIST AS
2 (
3 SELECT 1 AS POSITION_ID, 1 AS USER_ID, TRUNC(SYSDATE) AS UPD_DATE FROM DUAL UNION ALL
4 SELECT 1 AS POSITION_ID, 1 AS USER_ID, TRUNC(SYSDATE)+1 AS UPD_DATE FROM DUAL UNION ALL
5 SELECT 1 AS POSITION_ID, 1 AS USER_ID, TRUNC(SYSDATE)+2 AS UPD_DATE FROM DUAL UNION ALL
6 SELECT 1 AS POSITION_ID, 1 AS USER_ID, TRUNC(SYSDATE)+4 AS UPD_DATE FROM DUAL UNION ALL
7 SELECT 3 AS POSITION_ID, 2 AS USER_ID, TRUNC(SYSDATE) AS UPD_DATE FROM DUAL UNION ALL
8 SELECT 3 AS POSITION_ID, 2 AS USER_ID, TRUNC(SYSDATE)+1 AS UPD_DATE FROM DUAL UNION ALL
9 SELECT 3 AS POSITION_ID, 2 AS USER_ID, TRUNC(SYSDATE)+2 AS UPD_DATE FROM DUAL UNION ALL
10 SELECT 4 AS POSITION_ID, 21 AS USER_ID, TRUNC(SYSDATE)+2 AS UPD_DATE FROM DUAL
11 )
12 SELECT POSITION_ID
13 , USER_ID
14 FROM
15 (
16 SELECT POSITION_ID
17 , USER_ID
18 , UPD_DATE - LAG(UPD_DATE) OVER (PARTITION BY USER_ID ORDER BY UPD_DATE) AS LOGGED_IN_TIME
19 , ROW_NUMBER() OVER (PARTITION BY USER_ID ORDER BY UPD_DATE DESC) RN
20 FROM POSITION_HIST
21 )
22 WHERE LOGGED_IN_TIME > 1 AND RN = 1
23 /
POSITION_ID USER_ID
1 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • How to find face time in iPhone 5 bought from Dubai

    How to find face time in iPhone 5 bought from Dubai

    Read the fine print at the bottom.
    Some features may not be available for all countries or all areas. Click here to see complete list.
    And the note for UAE on this page: http://support.apple.com/kb/ht1937
    FaceTime is not available in this country.

  • How to populate date & time when user enter data for custom table in sm30

    Can anyone tell me How to populate system date & time when user enter data for custom table in sm30..
      Req is
      i have custom table and using sm30 user can enter data.
    after saving date i want to update date & time in table
    Pls let me know where to write the code?
    Thanks in Advance

    You have to write the code in EVENT 01 in SE54 transaction. Go to SE54, enter your Ztable name and in the menu 'Environment-->Events'. Press 'ENTER' to go past the popup message. In the next screen, click on 'New Entries'. In the first column, enter 01 and in the next column give some name for your routine(say UPDATE_USER_DATE_TIME). Then click on the souce code icon that appears in blue at the end of the row. In the code, you need logic like below.
    FORM update_user_date_time.
      DATA: f_index LIKE sy-tabix.
      DATA: BEGIN OF l_total.
              INCLUDE STRUCTURE zztable.
      INCLUDE  STRUCTURE vimtbflags.
      DATA  END OF l_total.
      DATA: s_record TYPE zztable.
      LOOP AT total INTO l_total.
        IF l_total-vim_action = aendern OR
           l_total-vim_action = neuer_eintrag.
          MOVE-CORRESPONDING l_total TO s_record.
          s_record-zz_user = sy-uname.
          s_record-zz_date = sy-datum.
          s_record-zz_time = sy-uzeit.
          READ TABLE extract WITH KEY l_total.
          IF sy-subrc EQ 0.
            f_index = sy-tabix.
          ELSE.
            CLEAR f_index.
          ENDIF.
          MOVE-CORRESPONDING s_record TO l_total.
          MODIFY total FROM l_total.
          CHECK f_index GT 0.
          MODIFY extract INDEX f_index FROM l_total.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " UPDATE_USER_DATE_TIME
    Here ZZTABLE is the Z table and ZZ_USER, ZZ_DATE, and ZZ_TIME are the fields that are updated.

  • Query to find three times greater than the other records

    hi All,
    I am new to this forum, please help me out on this issue.
    There is a table named as regions which has following columns like name, region, population, area with the following sample records
    Region Name Population
    AAA AAAA 1000
    AAA BBBB 2000
    AAA CCCC 500
    BBB DDDD 900
    BBB EEEE 300
    I need to pick the record which has population more than three times that of any of their neighbours (in the same region). I need to get the region and name as the output. Please help me on how to write this query.

    with
       your_data as
       select 'AAA' as col1, 'AA' as col2, 7000   as col3 from dual union all
       select 'AAA' as col1, 'BB' as col2, 2000   as col3 from dual union all
       select 'AAA' as col1, 'CC' as col2, 500    as col3 from dual
    select *
    from
       select
          col1,
          col2,
          col3,
          case when col3 >= lag(col3) over (partition by col1 order by col3 asc) * 3
          then
             dense_rank() over (partition by col1 order by col3 desc)
          else
             0
          end as the_rank
       from
          your_data
    where
         the_rank = 1;
    COL CO               COL3           THE_RANK
    AAA AA               7000                  1
    1 row selected.
    Elapsed: 00:00:00.01
    TUBBY_TUBBZ?This code will return AT MOST one name for each region (assuming 1 or more qualify based on your description).
    Is that what you want?

  • How to display a time greater than 24hrs?

    Hi all
    I am trying to create a wages tracker by entering start and finishing times for each day, working out the time worked and then adding it all together to get a weekly value. This works fine and if I have 5 days at 9hrs it correctly gives me 45h.
    Then I want to create an IF function to say if the total hours worked for that week are more than 35h display the amount of overtime worked (in this case it would be 10h) else display "No OT Worked".
    This is what I have so far but all I get is "Durations can't be compared to other data types". I'm guessing it's because in the IF formula I have specified 35 and with this being a number and not a time it's giving the error. Can anyone help me solve this please :-)
    Thanks

    Crofty,
    You should be able to get the "35h" to work. It's so much handier than the DURATION function that it would be worth it to learn to use the direct notation.
    When you tried using "35h", what didn't work. Did you get an error message, a wrong result?
    Jerry

  • We have two remote location when we makes this remote location pc member of domain (Remote location connected leaselan) it's taking login time more than 40/45 minutes.

    We have two remote location when we makes this remote location pc member of domain (Remote location connected leaselan)
    it's taking login time more than 40/45 minutes.
    Pls suggest.

    Hi,
    It might be Group Policies causing the login process slow.
    Remove any GPOs with Wallpaper or logon scripts on the user\computer account and try again.
    Regards,
    Satyajit
    Please “Vote As Helpful”
    if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

  • What can I do to increase battery usage time to greater than 6 hours?

    What can I do to increase battery usage time to greater than 6 hours?     I have a New iPad purchased 03/23/2012 64K-WiFi.    I recharge it and get another 6 hours usage.  I am using it primarily for reading books.  Are there any applications I can turn off to get back to 10 hours?

    @Ralph9430   The changes you recommended were implemented.  This afternoon approximately at the same time and with similar usage all day The New iPad had 36% left on battery.  This is a gain of 30% battery life.  Thank you.  Your suggestions resolved the issues.

  • Confirmation activity:start time greater than remaining start time

    Hello Experts
    While CIFing Production orders I am getting the above error "confirmation activity:start time greater than remaining start time". or sometimes the error says "invalid confirmed start time of an activity"
    I have checked the inter operation times for the operations & have ensured that the Min & max values are same.
    I have attached the screen shot also.
    Kindly advise
    Regards
    Soum

    Hello,
    I guess you háve implemented BAdI method MODIFY_AFTER_MERGE (/sapapo/cl_ex_cif_ip in SE18).
    Deactivate it.
    The mentioned error means that an activity has its  start date larger than confirmed date that's wrong for liveCache.
    Standa

  • How to find max(time) from table using group by

    how to find max(time) from table using group by
    select var max(time)
              from table
              into (var1, time1)
               where .....
                 group by var.
    it is fetching record which is top in table.
    if u can help?
    regards.

    No this will fetch the maximum time from teh table.
    select var max(time)
    from table xxxx
    into (var1, time1)
    where .....
    group by var.
    Refer this code
    TABLES SBOOK.
    DATA:  COUNT TYPE I, SUM TYPE P DECIMALS 2, AVG TYPE F.
    DATA:  CONNID LIKE SBOOK-CONNID.
    SELECT CONNID COUNT( * ) SUM( LUGGWEIGHT ) AVG( LUGGWEIGHT )
           INTO (CONNID, COUNT, SUM, AVG)
           FROM SBOOK
           WHERE
             CARRID   = 'LH '      AND
             FLDATE   = '19950228'
           GROUP BY CONNID.
      WRITE: / CONNID, COUNT, SUM, AVG.
    ENDSELECT.

  • How to find the time difference..?

    HI
    How to find the time difference between two times
    for Example
    the difference between '24/10/2005 8:25:00 PM' and '25/10/2005 5:20:00 AM'
    is 8.55
    Kris

    This is a procedure taht do the job
    CREATE OR REPLACE FUNCTION Diff_Time
         LD$Date_Deb IN DATE DEFAULT SYSDATE
         ,LD$Date_Fin IN DATE DEFAULT SYSDATE
         ,LN$JJ       OUT PLS_INTEGER
         ,LN$HH       OUT PLS_INTEGER
         ,LN$MI       OUT PLS_INTEGER
         ,LN$SS       OUT PLS_INTEGER
      ) RETURN NUMBER
    IS
      dif   NUMBER ;
    BEGIN
      IF LD$Date_Fin < LD$Date_Deb THEN
         RETURN ( -1 ) ;
      END IF ;
      SELECT  LD$Date_Fin - LD$Date_Deb INTO dif  FROM dual ;
      SELECT  TRUNC ( LD$Date_Fin - LD$Date_Deb)  INTO LN$JJ  FROM dual ;
      SELECT  TRUNC ( (LD$Date_Fin - LD$Date_Deb) * 24) -  ( LN$JJ * 24 ) INTO LN$HH FROM dual ;
      SELECT  TRUNC ( (LD$Date_Fin - LD$Date_Deb) * 1440) - ( (LN$HH * 60) + ( LN$JJ * 1440) ) INTO LN$MI FROM dual ;
      SELECT  TRUNC ( (LD$Date_Fin - LD$Date_Deb) * 86400) - ( (LN$MI * 60) + (LN$HH * 3600) + ( LN$JJ * 3600 * 24 ) ) INTO LN$SS FROM dual ;
      RETURN( dif ) ;
    END ;
    /You may have to modify it to fit your own requirement.
    Francois

  • How do I download files greater than 200MB to my Iphone now my music is in the iCloud?

    How do I download files greater than 200MB to my Iphone now my music is in the iCloud? I still have my music on my hard drive of course.

    Go to settings --> store --> and make sure automatic downloads for music is on.  If you download music in iTunes, it should automatically download to your phone.

  • How do I find the time capsule serial number remotely from my mac?

    How do I find the time capsule serial number remotely from my mac?

    Hi All,
    I found it in my Support profile.  https://supportprofile.apple.com.
    Thanks.
    Richie

  • How to find out that particular structure is used in which tables

    Hello Friends,
    Most of the times through techinal information we come to know the table name for a particular field.And in se16 when i give that table name than system says its structure and not the table.So in se11 when i give that structure name in database table field, its shows all the field in that structure, but not the data stored in that field.
    So my question is how to find out that particular structure is used in which tables,so that i can view data stored in that structure?
    Thanking you guys in advance.
    Regards,
    Jitendra

    Dear,
    When you click on the technical information it will give the structure name and field, double click on the structure and it will take you the display structure screen, there you will have the where-used List icon (Ctrl + Shift + F3) at the top , click on that and it will show the options, select Database tables and execute, it will give the tables related to the structure, you can explore the list of tables and find where your required field is stored in them.
    Thanks & Regards,
    Vijaya Bhaskar A

  • Advanced find - Case modified older than 4 hours

    Hi there,
    For CRM 2011 on premise
    I'd like to have an advanced find date option that says "Older that x hours" as i'd like to find cases that have not been modified for 4 hours.  (there already is an older than x months option).
    Or if there was a way to add a NOT function to a clause we could do this with cases edited in the last week and NOT modified in the last 3 hours.
    Would either of these possible please?
    Kind regards,
    Stuart
    Stuart

    There is no way to do this by default as you are unable to use advanced find to filter on hours, minutes and seconds. All though these are defined in the date-time format.
    To accomplish this you would need to make a custom developed list.
    I cant even see you completing this request with any other semi-default functionality. I have tried thinking the cases through if you extract the HH from the date-time info, and that would work, but you would be missing the information on  your current
    date-time, which wouldnt allow you to search for values that are greater than 4 hours difference.
    So.. custom development unfortunetly.
    Rune Daub Senior Consultant - Dynateam CRM http://www.dynateam.dk

  • How can I login and retrieve my user file from the trash?

    I was trying to find out where all my HD had gone, which a did using ‘What Size’.
    I found what looked like an old backup file so I put the file in the trash.
    It turns out that the file was my user file. So now I can’t login to as the user.
    How can I login and retrieve my user file from the trash?

    The Digital Editions forum is here, in case this is what you are talking about:
    http://forums.adobe.com/community/adobe_digital_editions
    If you are not, I apologize for the misunderstanding.

Maybe you are looking for

  • Can not open Events photos in iPhoto 9.5.1

    can not open Events photos in iPhoto 9.5.1

  • Report Column Sorting problem

    I have a report based on a view. For some reason some of the columns are not being sorted correctly. After pressing the column header to sort date columns the underlying data is not sorted properly (it’s out of order) or it’s not sorted at all. Can y

  • Solaris 8 (x86) 2/02 support IDE drivr than 20GB?

    Would like to find out from those who had tried installing Solaris 8 (x86) 2/02 on an IDE drive with capacity larger than 20 GB, say 40 GB or more?? Thanks your advice!

  • Extra Pages

    I have a form with 2 master pages. Master page 1 is a title page and Master 2 is used for the remaining 7 pages. When I view the form in Design mode or Preview there are an extra 2 pages. Page 3 and 9 are phantom pages - there should only be 8. They

  • Please help me!!!!!!urgent!!!!!!!!!!!!!!!!!!!!!sos!!!!!!!!!

    compile error!           HPUX11+wl51+sp5           this is the error message:           weblogic.utils.compiler.CodeGenerationException: Neither method nor           production rule found for ' ' in /weblogic/servlet/jsp/jspservlet.j at line