Latest two max

Hi
I have query
select * from
(select Server,CPU_TOT_UTIL,RUNDATETIME,dense_rank() over (partition by Server order by RUNDATETIME desc) rnk from utlz_tab
where RUNDATETIME > sysdate-1)
where rnk <3
Which gives following result set
SERVER     CPU_TOT_UTIL     RUNDATETIME     RNK
A     64     02/15/2010 06:58:52     1
A     77     02/15/2010 06:43:51     2
B     78     02/15/2010 07:01:01     1
B     94     02/15/2010 06:46:01     2
C     32     02/15/2010 06:58:52     1
C     33     02/15/2010 06:43:51     2
D     23     02/15/2010 06:58:52     1
D     52     02/15/2010 06:43:51     2
E     93     02/15/2010 06:56:51     1
E     100     02/15/2010 06:41:51     2
F     68     02/15/2010 07:00:21     1
F     27     02/15/2010 06:45:19     2
G     14     02/15/2010 07:01:19     1
G     66     02/15/2010 06:46:19     2
H     19     02/15/2010 07:00:53     1
H     24     02/15/2010 06:45:53     2
Objective: finding cpu usage for last two timestamp may be interval of (15 mins).
Output required here is when a server having cpu usage >90 for its last two timestamps.
Result would be for my example
SERVER     CPU_TOT_UTIL     RUNDATETIME     RNK
E     93     02/15/2010 06:56:51     1
E     100     02/15/2010 06:41:51     2
Please help me to get this result.
Thanks
Ranga

You can use lag and lead functions:
select * from
(select Server,CPU_TOT_UTIL,RUNDATETIME,dense_rank() over (partition by Server order by RUNDATETIME desc) rnk,
lag(CPU_TOT_UTIL) over (partition by Server order by RUNDATETIME desc) prev_cpu,
lead(CPU_TOT_UTIL) over (partition by Server order by RUNDATETIME desc) next_cpu
from utlz_tab
where RUNDATETIME > sysdate-1)
where rnk <3
and CPU_TOT_UTIL>90
and (prev_cpu>90 or next_cpu>90)Max
http://oracleitalia.wordpress.com

Similar Messages

  • Does the latest Gateway Max adsl router support the 4g mobile dongle?

    our landline is being delayed by cabling shortfalls to our property and the Telstra "Move Team" suggested we buy a 4g dongle to share, my 3 year old router only supports G3 dongles and doesn't load the G4 version so I'm wondering if we were to get the latest Gateway Max whether that would. At least our mobile devices like iPads etc would function over wifi.
    I found a little info on the gateway max 799 and it just says G3 but would like to know if the G4 dongle will just step down in this router?
    Thanks in advance.

    Hi, I also have the Telstra Gateway Max and I want to install the 4G USB dongle to provide internet fallback for when the landline fails (which appears to be happening a lot more often over the last two months - up to 21 days in total so far). I went to the Telstra shop today and bought the Telstra 4G USB+WiFi Plus dongle which I am told should work with the Gateway Max. However, nobody there could tell me what to do to get it working. They said simply plug it in and it should work. I did this and of course it did not!! Does anyone know how to configure the Gateway Max to see and use the dongle when the ADSL/Landline service fails next time? I will be able to test if it is working by unplugging the ADSL service from the DSL port on the Gateway Max - that part is the easy bit. If there is a guide somewhere on Telstra's site on how to do the configuration work that would be great. Otherwise any help would be just as great I'm sure!! CheersCraig

  • Time Machine deletes all but latest two backups

    Hello,
    Today I was backing up my macbook, with about 38 GB of space left on my harddrive, and Time Machine deletes everything but the latest two backups (from Feb 2012 to May 2012).... I had things on there from 2009. TM preferences now says I have 27 GB of free space, after the latest backup. I didn't have anything big enough on my computer to be backed up that justified deleting years of data, over 200 GB, in order to compensate for the new data that had to be backed up. Is there any way to recover the files that were erased off of my external hard-drive that were deleted during Time Machine's semi-routine back up?
    Thank you

    Sebastian Kuhn wrote:
    Is there no way to set up Time Machine such that it will ASK before destroying a (potentially valuable) "old" backup
    That's how it worked at first, on Leopard.  But many users either didn't understand it, or never got around to doing anything, so had no backups at all when disaster struck.  It was fairly common, so Apple changed it with Snow Leopard.
    Why does Apple assume that it is always the OLDEST backup (which will be hardest to retrieve) that people would be willing to loose?
    That's usually correct.  Time Machine is not a traditional archive-type app;  if you need archives, make archives.
    If you frequently need things from your backups, you may have a deeper problem.  But most likely, you just need a larger backup drive. 
    That all applies to the vast majority of users -- they have a single internal HD with less than 1 TB of data, so a 2 TB backup drive is ok, 3 TB large enough for most everybody.
    If that's not enough for your setup, you probably need a different strategy anyway.  You may have some data that changes frequently and should be backed-up hourly by Time Machine, plus something like a large media drive that's best backed-up only once a day or so by a different app, such as one of the "cloning" products. 
    there should be the option to exclude different items when backing up to different disks. Is there?
    No.  Apparently Apple wants to keep it as simple as possible, with  few options that may confuse some folks, so instead of making a decision, they do nothing  (that's not just Time Machine, either).  Remember, most of the folks using Time Machine have never used any backup app at all. 
    Apple's resisted all suggestions (and there have been many) for things like the ability to limit the size or age of backups, reduce the 10-day warning when no backup has been done, etc.  Like it or not, that's Apple's approach to pretty much everything -- streamlined, simple, easy to use.  Very successful for the majority.
    Is there any workaround other than the cumbersome procedure of turning Time Machine off, and under "options" re-select the correct set of folders to exclude every time I move from one disk to another? Not exactly what I would call a user-friendly interface...
    Best of course, is get a larger disk.  Is your data worth the price of a 2 TB disk? 
    There are some elaborate workarounds involving automatically swapping destinations and exclusions, but they're very "iffy" as they do things that TM (and OSX) don't anticipate so don't react well to.
    Effective with Lion, however, there's a new tmutil command that in theory would allow you to write an AppleScript to set a destination, add or remove exclusions and run a backup.  Many things could go wrong, of course, but I know of no way to detect which destination is available. 
    Much safer, easier, and more reliable to get a larger drive (or better strategy).

  • Difference between N-80 latest two updates?

    hey guys,
    can anyone tell me what are the differences between the latest two firmware updates for N-80
    V4.0623.0.41 & V4.0623.0.42
    did anyone notice any changes? when I tried to update over the air from V4.623.0.41 it was showing that there are no updates available.......any comments everyone?
    thanks guys in advance...
    good day.

    Are you sure that the first query works?
    SRVY_EMPLOYEE_IDThe above column is in GROUP BY clause, but not in the SELECT...

  • Query to find the latest two transactions for each Group

    Hi All,
    Consider the following sets of records in a table test.
    Group---Tran_Dt---SlNo
    c1 10/10/2003 1
    c1 10/10/2003 2
    c1 10/10/2003 3
    c1 11/10/2003 1
    c2 10/10/2003 1
    c2 10/10/2003 2
    c2 11/10/2003 1
    c2 11/10/2003 2
    c2 11/10/2003 3
    c3 10/10/2003 1
    c3 10/10/2003 2
    c3 10/10/2003 3
    I want to list out the latest two transactions for each group irrespective of the slno and trans_dt as below:
    group tran_dt SlNo
    c1 11/10/2003 1
    c1 10/10/2003 3
    c2 11/10/2003 3
    c2 11/10/2003 2
    c3 10/10/2003 3
    c3 10/10/2003 2
    Any help on this would be appreciated.
    Thanks
    Walter Nicholas T

    Hi Walter,
    Please try following query.
    select Group,tran_dt,sino from
    select Group,tran_dt,sino,(DENSE_RANK()OVER (PARTITION BY Group ORDER BY tran_dt desc,sino desc)) rank from test
    ) where rank between 1 and 2
    Thanks,
    Samir

  • In the latest two updates you can only go back one page at a time, previous versions allowed you to jump back several pages by choosing from the twistie - any suggestions?

    In the latest two updates you can only go back one page at a time, previous versions allowed you to jump back several pages by choosing from the twistie - any suggestions?

    The arrow to open the tab history of the Back and Forward buttons has been removed in Firefox 4 and later.
    Use one of these methods to open the tab history list:
    * Right click on the Back or Forward button
    * Hold down the left mouse button on the enabled Back or Forward button until the list opens
    You can look at this extension:
    * Backward Forward History Dropdown: https://addons.mozilla.org/firefox/addon/backforedrop/

  • Select latest two records per group

    hi there,
    i've been googling around and still can't really find an appropriate solution to retrieve two most recent records per group in one sql. Is this even possible?
    Let's say there is a MyLife table :
    ID, Event , RecordedDate
    1. 1, 'Fell down the stairs', '20-DEC-07'
    2. 1, 'Fell down the stairs', '22-DEC-07'
    3. 1, 'Fell down the stairs', '23-DEC-07'
    4. 2, 'Tried to kiss santa', '23-DEC-07'
    5. 3, 'Reindeer stolen', '24-DEC-07'
    6. 4, 'Chimney Broke', '25-DEC-07'
    Output should be :
    2. 1, 'Fell down the stairs', '22-DEC-07'
    3. 1, 'Fell down the stairs', '23-DEC-07'
    4. 2, 'Tried to kiss santa', '23-DEC-07'
    5. 3, 'Reindeer stolen', '24-DEC-07'
    6. 4, 'Chimney Broke', '25-DEC-07'

    I believe that something along these lines would be portable to most other databases.
    SQL> SELECT id, event, recordeddate
      2  FROM mylife o
      3  WHERE recordeddate = (SELECT MAX(recordeddate) FROM mylife i
      4                        WHERE o.id = i.id)
      5  UNION ALL
      6  SELECT id, event, recordeddate
      7  FROM mylife o
      8  WHERE recordeddate = (SELECT MAX(recordeddate) FROM mylife i
      9                        WHERE o.id = i.id and
    10                              i.recordeddate < (SELECT MAX(recordeddate)
    11                                                FROM mylife ii
    12                                                WHERE i.id = ii.id))
    13  ORDER BY id, recordeddate;
            ID EVENT                     RECORDEDDAT
             1 Fell down the stairs      22-DEC-2007
             1 Fell down the stairs      23-DEC-2007
             2 Tried to kiss santa       23-DEC-2007
             3 Reindeer stolen           24-DEC-2007
             4 Chimney Broke             25-DEC-2007John

  • Why is the latest update maxing out my CPU

    After my Firefix updated the last time to 14.0.1, it has been totally unusable. As soon as it starts it just about maxes out my CPU's. Trying to do anything in it is impossible, menus take 4-5 seconds before they open. If I can get to a web site, trying to scroll down a web page takes several seconds to wait for each click to respond. Even typing in information takes several seconds between key strokes.
    I've been a long time user of Firefox, but this has been the worse update and I'm preparing to move to another browser.

    What kind of images are causing the problems?
    Did you check that it isn't caused by JavaScript that is running on those pages?

  • Lightroom 3.3 blew away all my library folders except the latest two

    All folders except the two most recent are no longer there.   The only thing I have done recently is imported 197 raw files last night. 
    Any help greatly appreciated

    XfreezeframeX wrote:
     I loaded a couple sets of raws with the wrong drive letter assigned so I need to get lightroom to work with the preview thumbnails already created etc.  hopefully without having to load catalogs back and forth everytime I access them
    Right click the highest level folders with a "?", do a "Find missing Folder" and point to the location on the external with the correct drive letter.
    Beat

  • My iPhone 4S camera needs a lot of time to open, after the latest two iOS 6 updates, help?

    Whenever I tap on the camera app, it opens, but I can't take any pictures! It only shows a black screen ( the one that appears when you switch from camera to video) but it doesn't open and it doesn't show the scene or whatever is in front of the camera.
    That is really annoying, it started to happen after that major update that took a lot of time (the first iOS 6 update) and continued after the second,I thought that the second would fix it but it didn't.
    I'm using an iPhone 4S.
    Did this happen to anyone else? If so how did you fix it? -if you did-
    I hope that I get some help about this, it's really annoying me a lot!
    Thanks!

    Try resetting your phone by holding down the home and off button until the apple symbol comes up. Then if still doing, restore your phone in itunes from your backup.

  • My latest two extension updates constantly show up as tabs each time I start FireFox. Where should I look to make this stop?

    WebMail and Xmarks have constantly and consistently shown up as update notification tabs each time I start FireFox. That never used to happen. Is there somewhere I can look to shut off this annoying action. Thanks.

    See these articles for some suggestions:
    * https://support.mozilla.com/kb/Firefox+has+just+updated+tab+shows+each+time+you+start+Firefox
    * https://support.mozilla.com/kb/How+to+set+the+home+page - Firefox supports multiple home pages separated by '|' symbols
    * http://kb.mozillazine.org/Preferences_not_saved

  • After the latest two updates, whenever Firefox starts, the print dialog box appears automatically. Why, and how do I stop this?

    Not much else to add. The print dialog box just opens every time Firefox is started or restarted.

    Check the Home page setting:
    *https://support.mozilla.com/kb/How+to+set+the+home+page
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode

  • Latest Address and the Previous Address in the last 30 days

    Morning folks.
    I need to find out all Customers whose Address changed based on the Effective Date. The Query should be based as of Effective Date 01-JUN-12 and not SYSDATE. So, we want to check the MAX(effective_date) is <= 01-JUN-12 and the Previous Address's Effective Date is between 02-MAY-12 and 01-JUN-12 (30 days). This would suggest that an Address has changed. For argument sake, the Zip Code is enough to differentiate that an address has changed for now.
    Based on the data, I only want to pick up Customer 1002 but not 1001, 1003. As for Customer ID 1003, even though his/her address changed in the last 30 days, we are not interested as the Address effective 1st June was good for a long time.
    Also, even though the Address for Customer ID 1001 changed twice in that period, I am only interested for the latest two addresses.
    Table CUST_ADDRESS
    CREATE TABLE CUST_ADDRESS
        "CUST_NO"  VARCHAR2(4 BYTE) NOT NULL,
        "STREET"   VARCHAR2(20 BYTE),
        "CITY"     VARCHAR2(20 BYTE),
        "STATE"    VARCHAR2(2 BYTE),
        "ZIP_CODE" VARCHAR2(9 BYTE),
        "EFFECTIVE_DATE" DATE
      );INSERT Script
    Insert into CUST_ADDRESS (CUST_NO,STREET,CITY,STATE,ZIP_CODE,EFFECTIVE_DATE) values ('1001','123 Picket Fences','Santa Ana','CA','92704',to_date('31-MAY-12','DD-MON-RR'));
    Insert into CUST_ADDRESS (CUST_NO,STREET,CITY,STATE,ZIP_CODE,EFFECTIVE_DATE) values ('1001','12259 Circular Dr','Irvine','CA','92705',to_date('10-APR-12','DD-MON-RR'));
    Insert into CUST_ADDRESS (CUST_NO,STREET,CITY,STATE,ZIP_CODE,EFFECTIVE_DATE) values ('1001','22 Green Road','Newport Beach','CA','92709',to_date('03-JAN-12','DD-MON-RR'));
    Insert into CUST_ADDRESS (CUST_NO,STREET,CITY,STATE,ZIP_CODE,EFFECTIVE_DATE) values ('1002','12 Parkside Dr','Chicago','IL','60601',to_date('20-MAY-12','DD-MON-RR'));
    Insert into CUST_ADDRESS (CUST_NO,STREET,CITY,STATE,ZIP_CODE,EFFECTIVE_DATE) values ('1002','3200 Court Road','Indianapolis','IN','46201',to_date('02-MAY-12','DD-MON-RR'));
    Insert into CUST_ADDRESS (CUST_NO,STREET,CITY,STATE,ZIP_CODE,EFFECTIVE_DATE) values ('1003','24 Jaeger St','Bellingham','WA','98225',to_date('01-JUL-12','DD-MON-RR'));
    Insert into CUST_ADDRESS (CUST_NO,STREET,CITY,STATE,ZIP_CODE,EFFECTIVE_DATE) values ('1003','145 NE 38th St','Fort Lauderdale','FL','33334',to_date('18-JUN-12','DD-MON-RR'));
    Insert into CUST_ADDRESS (CUST_NO,STREET,CITY,STATE,ZIP_CODE,EFFECTIVE_DATE) values ('1003','212 Coral Drive','Miami','FL','33010',to_date('01-JAN-95','DD-MON-RR'));Thanks a bunch.
    Edited by: Roxyrollers on Jul 26, 2012 9:35 AM

    Something like this
    SQL> ed
    Wrote file afiedt.buf
      1  select *
      2    from (
      3  select ca.*,
      4         max(effective_date) over (partition by cust_no) max_eff_date,
      5         lag(effective_date) over (partition by cust_no order by effective_date) prior_eff_date
      6    from cust_address ca)
      7   where prior_eff_date between date '2012-05-02' and date '2012-06-01'
      8*    and max_eff_date <= date '2012-06-01'
    SQL> /
    CUST STREET               CITY                 ST ZIP_CODE  EFFECTIVE MAX_EFF_D PRIOR_EFF
    1002 12 Parkside Dr       Chicago              IL 60601     20-MAY-12 20-MAY-12 02-MAY-12Justin

  • How to fix extremely slow printing from web pages with latest updates (iMac) & HP Office jet printer. (It was not a problem with earlier versions of Firefox & same computer & printer.)

    The latest two updates of Mozilla Firefox are not useful for me because of extremely slow printing of web pages. It was never a problem before. Same iMac and HP officejet printer. How can I either fix it, or revert to an earlier version of the browser (without losing all my bookmarks) which didn't cause this problem?

    Try scanning from your Mac.  Use Image Capture app in your Applications folder.
    Click once on the scanner on the left side, then click on Show Details along the bottom.  Along the right side you will see LOTS of options for scanning and saving.
    Say thanks by clicking "Kudos" "thumbs up" in the post that helped you.
    I am employed by HP

  • Can any one tell me how to select latest record

    Hi,
    Can any one tell me how to select latest record. Below is the requirement
    select * from a where a_Date=v_date.
    out of thousand records with matched condition i need to select latest record
    Thanks in advance

    user12852882 wrote:
    Can any one tell me how to select latest record. Below is the requirement
    select * from a where a_Date=v_date.
    out of thousand records with matched condition i need to select latest recordHow do you determine the "latest" row? From your description it sounds like the following SQL will define the latest:
    select max(a_date) from aThis will return the last/latest date used from the table.
    Secondly, you now want to select the last row - or rows. As a_date may not be a primary key (you did not state it was and usually a date column make poor choice as unique identifier), there could be more than one row with that "+latest date+".
    So to find the latest row(s):
    select * from a where a_date = (select max(a_date) from a)Or you could do the following:
    declare
      latestDate date;
    begin
      // find the latest date and store it for use and re-use
      select max(a_date) into latestDate from a;
      // now process the last row(s) - and consider rewriting this
      // as a bulk processing loop
      for c in (select * from a where a_date = latestDate)
      loop
        .. do something with the row
      end loop;
      // now use latestDate variable for some other
      // required processing
    .. code goes here ...
    end;

Maybe you are looking for

  • IPhoto 6: Just installed and have many questions!

    I have just installed iLife 06, and my life seems to be much more difficult. Am I missing something here? Hope someone can help me. 1) When I installed iPhoto 6, I was asked to upgrade my Library so that iPhoto 6 can read it, so I did. What I noticed

  • How to generate TS_error using background VI

    Hello everyone. I have a problem with seting TestStand properties using LabVIEW. My sequence is working in while loop (till termination). There is a VI running in background (it could LabVIEW exe file, not in TS sequence) waiting for an user event. A

  • Prinitng smartform tables in full sheet

    Dear All Gurus, This is my request. I need to print a customized smartform (ex :GRN) according to below. Format of Smartform(1 page Smartform) : Header Windows (Adress / LOGO) Table Data Footer window (signatuees / agreement texts) (If the smartform

  • Developing FSG reports in BI

    Hi, I am developing the concept of FSG reports in BI using FSG backend tables. The concurrent program for FSG Reports 'Financial Statement Generator' is a Spawned program. I don't know what is the functionality of this program and how the calculation

  • Work Item forwarding problem

    Hi All, Right now we have a interesting workflow problem. we applied support pack in the month of September after that forwarded work items are getting disppered from the users inbox If user A forwarded the work item to User B he is getting it, But i