Keep Dense_rank() Last

I am using said function in my query
SQL> select job,  max(hiredate) keep (dense_rank last order by hiredate) Hdate from emp
  2  group by job
  3  ;
JOB       HDATE
ANALYST   19-APR-87
CLERK     23-MAY-87
MANAGER   09-JUN-81
PRESIDENT 17-NOV-81
SALESMAN  28-SEP-81Can I use here Dense_rank second last () here ?
I I want to fetch second last record instead of Last record what should I do?
kindly help.
OR
I have another Query
SQL>  select job,hiredate,rn from (
  2   select job,  hiredate, dense_rank() Over (order by hiredate) Rn
  3   from emp)
  4   where rn <= 7
  5  /
JOB       HIREDATE          RN
CLERK     17-DEC-80          1
SALESMAN  20-FEB-81          2
SALESMAN  22-FEB-81          3
MANAGER   02-APR-81          4
MANAGER   01-MAY-81          5
MANAGER   09-JUN-81          6
SALESMAN  08-SEP-81          7
7 rows selected.Is this possible that I can calculate Last Two Date Difference of Job wise.
Like Salesman has 2 records hiredate 20-feb-81 and 22-feb-81 I want to calculate last 2 date difference.
other example
Manager Has 3 records Last 2 dates are 01-May-81 and 09-Jun-81 so calculate the difference.
Edited by: 867210 on Jul 6, 2011 4:06 AM

867210 wrote:
Can I use here Dense_rank second last () here ?You could specify only FIRST or LAST here.
Though there are other methods available to get the "second last" hiredate.
SQL> SELECT job,
  2         hiredate
  3  FROM   (SELECT job,
  4                 hiredate,
  5                 Dense_rank() OVER(PARTITION BY job ORDER BY hiredate DESC) dr
  6          FROM   emp)
  7  WHERE  dr = 2  ;
JOB       HIREDATE
ANALYST   03-DEC-81
CLERK     23-JAN-82
MANAGER   01-MAY-81
SALESMAN  08-SEP-81
4 rows selected.

Similar Messages

  • Syntax is not correctly checked while using keep dense_rank

    Hi,
    Looks like Oracle doesn't check the syntax correctly, "order" is not required to write before "by" in keep (dense_rank...).
    DB version 11.1.0.6
    SQL> with t as (select 5 val, 2 val2 from dual union all
      2  select 1 val, 9 val2 from dual union all
      3  select 2 val, 9 val2 from dual)
      4  select sum(val) keep (dense_rank last blabla by val2) total_9 from t;
       TOTAL_9
             3Looks like a bug or what?

    Did you get any error in 10g?
    It is running in my 10g, too.
    I've to modify your query as i'm running this in Oracle 8 client. ;)
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    real: 30
    satyaki>
    satyaki>
    satyaki>
    satyaki>select sum(val) keep (dense_rank last blabla by val2) total_9
      2  from (
      3         select 5 val, 2 val2 from dual union all
      4         select 1 val, 9 val2 from dual union all
      5         select 2 val, 9 val2 from dual
      6     );
      TOTAL_9
            3
    real: 11
    satyaki>
    satyaki>
    satyaki>with tt
    unknown command "with tt" - rest of line ignored.
    satyaki>as (
    unknown command "as (" - rest of line ignored.
    satyaki>       select 5 val, 2 val2 from dual union all
      2         select 1 val, 9 val2 from dual union all
      3         select 2 val, 9 val2 from dual
      4     )
      5  select sum(val) keep (dense_rank last blabla by val2) total_9
      6  from tt;
    ERROR at line 4:
    ORA-00933: SQL command not properly ended
    real: 70
    satyaki>Regards.
    Satyaki De.

  • [Solved] Keep the last button pressed with a custom style

    Hello,
    I have a VBox with 20 buttons and I have this style applied (menu.css) (only for VBox wrapper):
    .button:focused {
        -fx-background-color: #0768A9;
        -fx-text-fill: #FFFFFF;
    But when I pressed other button outside the VBox the style disappears, because the other button get the focus.
    I'm afraid I'm taking the wrong way.
    How I can do to keep the last button pressed with a custom style? (Only for buttons containing the VBox).
    Best regards

    I created a simple method to change background colors in buttons:
        private void setSelectedBtnStyle(Button bboat) {
      // Change style oldSelectedBoat
        selectedBoat.setStyle("-fx-background-color: white;-fx-text-fill: black;");
        // oldSelectedBoat var change to newSelectedBoat
        this.selectedBoat = bboat;
      // Change style newSelectedBoat
        selectedBoat.setStyle("-fx-background-color: #0768A9;-fx-text-fill: #FFFFFF;");;
    Surely not the best solution, but it works for me.
    Best regards.

  • I just purchased an external disk drive to store my pictures.  I want to keep the last 12 months of pictures on my iMac and move the rest to the new external drive.  As new pictures are added I want them to be put on the iMac internal drive.  How?

    I just purchased an external disk drive to store my growing number of pictures.  I want to keep the last 12 months of pictures on my iMac and move the remaining pictures to the new external drive.  As I take more pictures I want them to be put on the iMac internal drive.  Every 3 to 6 months I would then move some additional pictures to the external drive.  I am nuervous about losing any of the pictures and want to make sure I follow the proper procedure.  What is the right way to handle this?
    Thanks.

    Here's one way to do what you want:
    Make sure the drive is formatted Mac OS Extended (Journaled)
    1. Quit iPhoto
    2. Copy the iPhoto Library from your Pictures Folder to the External Disk.
    Now you have two full versions of the Library.
    3. On the Internal library, trash the Events you don't want there
    Now you have a full copy of the Library on the External and a smaller subset on the Internal
    Some Notes:
    As a general rule: when deleting photos do them in batches of about 100 at a time. iPhoto can baulk at trashing large numbers at one go.
    You can choose which Library to open: Hold down the option (or alt) key key and launch iPhoto. From the resulting menu select 'Choose Library'
    You can keep the Library on the external updated with new imports using  iPhoto Library Manager

  • Spry Accordion : How to keep the last panel ?

    Hi!
    In the div 'AccordionPanelcontent', i have links which open
    the same page. The opening index is on 0. If the user is on an
    other panel than the first, and he click on a link, the page is
    refreshed nromally, but the accordion come back an opens the first
    panel. How do you do if you don't want the widget to move when you
    click or a link and that it keeps the last panel opened ?
    Thanks!

    Hello Sheeba,
    It will store previous selection.
    I think you did following steps:
    1. Creating Parameter
    2. Applying Expert on report.
    If you refresh then it asks for "Used value" Or "New value"... If you do it second time it shows previous selection also.
    please check it once...
    Thank You !

  • Premiere 6.5-how to keep the last image stay after movie's over?

    Hi.
    I am using Adobe Premiere 6.5.
    I like to keep the last image to stay after movie/ animation finished to play, but they disappear and shows the "x" mark.
    How can I leave the last image stays after they are done playing? Please help with this?
    thanks.

    Welcome to the forum. What you are referring to is a Freeze Frame.
    Though I like John T's method (one that I use), you might want to look into Frame Hold, if it is in Pr 6.5. It works in a similar fashion, but I like the still for my Freeze Frames. Also, remember that you can adjust the Duration of the still, by click-dragging on the Tail, until it is as long as you need.
    Good luck,
    Hunt

  • How can I keep the last word without devision?

    Hallo! By applying page brake if it is a word at the end which has a syllable division the division line disappears so that I have an orthographic error: e.g. if the last word is "marketing" and is being devided:
    Before: End of current page: marke-
    Start of next page: ting.
    After applying page brake:
    End of current page: marke
    Start of next page: ting.
    How can I keep the last word without devision?

    In the Hyphenation Options dialog, uncheck the option "Hyphenate across
    columns"

  • How to keep the last slide image in the background during loading transition??

    Does anyone have any good strategies for using the last slide as a static background image when one swf file transitions to another during the loading process?  Basically, I'd like to keep the loading image ontop of the last slide during the transition.

    Does this fairly recent post help?
    http://forums.adobe.com/thread/561129
    Erik

  • Keeping the last slide on the screen when show is over

    I am hoping this is an easy solution. I am creating a slideshow which I am exporting to quicktime and what I am trying to do is keep the information from the last slide to stay on the screen without disappearing.
    Do anyone know how to do this?

    You can also set the poster image for the QT movie to be of the last slide so when the movie is not playing and not in pause it will default to the poster image. Set poster image for KN in QT inspector and for QT in QT Pro.
    If what Brief ly said is correct, no worries, if not set last slide to longest duration possible, duplicate the slide a few times and make a huge QT file of 30min of same image. Try using an efficient codec that realises the images isn't changing. No recommendations, you have to test for your particular image.

  • IWeb keeps opening last project worked on

    How do you make iWeb always offer you the choice to choose an existing project or start a new one at startup? It keeps opening the last project.
    I have removed all domain files from the usual iWeb folder.
    Thanks.
    Vincent
    PowerBook G4 17"   Mac OS X (10.4.5)   2 GB DDR SDRAM

    Thanks, Tom,
    I was afraid of that. That means you still have to manually hide a domain file after working on it so iWeb does not open it automatically. It would have been better if it gave you the choice of starting a new one or opening an old project every time you start it up.
    Or, even better, have a recent projects drop down list.
    But thanks! That does answer my question.
    Vincent
    PowerBook G4 17"   Mac OS X (10.4.5)   2 GB DDR SDRAM

  • Firefox only keeps 2 days history. I want to keep the last 50 days. I tell Firefox in the Tools:options menu, but still, only 2 days.

    Cannot seem to change Firefox so that it keeps more than 2 days history.

    You can look at these prefs on the about:config page to make sure that you keep history.
    *http://kb.mozillazine.org/browser.history_expire_days (180) (also affects saved form data)
    *http://kb.mozillazine.org/browser.history_expire_days_min (90)
    To open the <i>about:config</i> page, type <b>about:config</b> in the location (address) bar and press the "<i>Enter</i>" key, just like you type the url of a website to open a website.<br />
    If you see a warning then you can confirm that you want to access that page.<br />
    *Use the Filter bar at to top of the about:config page to locate a preference more easily.
    *Preferences that have been modified show as bold(user set).
    *Preferences can be reset to the default or changed via the right-click context menu.

  • Safari keeps loading last session window upon launch

    I have tried everything I know to delete the last session so that it doesn't come up overtime I close and restart Safari.  As a related issue, when I log back in to Yosemite, the same applications launch even though I do not have the reopen windows when logging back in checked.  Also, Systems Preferences loads with the sharing pane vice the main pane with all the options.

    For any one in the future with the same problem, I resolved it by opening Safari, waiting for the crash to come, and closing it. Then using the Safari menu, and going to "Reset Safari". You then need to QUIT Safari (almost like you'd install something and then restart your computer) and reopen it. Works fine now.

  • Iphone keeps remembering last created sms

    hi guys im new here just registered because i have came across a problem on my iphone 3gs running 3.1.2.everytime i go to create a new sms message one that i created from days ago pops up which i have to delete before i start a new one however this keeps happening everytime i go to create a new message its very annoying ive tried to delete the message cancel it save it as draft however nothing works ive even deleted all my messages turned the phone off and back on and still when i go to create a new message its there
    any help would be much appreciated thank you all

    Hi,
    If you haven't already, try restarting the iPhone by holding the Sleep/Wake button until the red slider appears> then slide to turn off> and turn the iPhone back on by pressing the Sleep/Wake again.
    If the issue persists, try updating the iPhone. This article: http://support.apple.com/kb/HT1414 will walk you through the update process.
    -Jason

  • I spend a lot of time arranging my tab groups in the tab group view. But Panorama keeps rearranging them whenever I open up firefox. How can I get it to keep the last arrangement I left the tab groups in?

    My laptop resolution changes many times a day because I use a docking station. I suspect that this could be causing Panorama to rearrange my tab groups. None the less, I would like it to stop! Anyone know how I can get it to comply?

    Hello. I have just tried this add-on you suggested, and no change.
    And no, there was no some other add-on before, not that I know about it. Mainly, I need this option while I'm on a forum (IP board powered), it is not really something so important, but it's neat function for me.
    So, to be more detailed - I read a certain topic on this forum, and some of the posts from other members contain YouTube screens (looking same as on the original YouTube page), showing the frame of a video.
    In earlier versions of Firefox, I used to click on a small YouTube logo button (right side, down, between "watch on full screen" and "watch later" buttons). Clicking on this button automatically opened new tab, leaving forum tab as it is, and in new tab original YouTube page, with that certain video. In the same time, in Google search page, when clicking on a link, all links were opening in the same tab.
    Now, after some of the latest updates of Firefox, I noticed that some default settings were changed - in Google search, clicking on a link always opens a link in a new tab. I have found out here on your forum how to set this back in about:config feature, and now I have again that links in a Google results page are opened in the same tab (that's the way I like it).
    But YouTube screens on this forum are now also being opened in the same tab, and that is what I don't like, and trying to change back.
    So, what I need: all links to open in the same tab after clicking, as I have it now, and YouTube screens (e. g. on this forum) to be opened in a new tab (by clicking on a small YouTube logo ("watch this video on YouTube").
    Pedantic I am, I know that, and I know that this may look silly to some people, but if there is a way to do something, please tell me.
    Thanks for answering, and best regards.
    P.S.
    Is it possible that forum updates changed my setting, and not the Firefox? Thanks again...

  • I can no longer open up any links on emails to any website. It just takes me to firefox but keeps the last page I was looking at. No problem using Safari however. ONly has happened since last update

    I have an imac and using lastest firefox update. No links open to any website using firefox when I click on link on email. No difference if I right click and choose to open the link either

    Hi Olivier,
    Thanks very much for that. it worked on my powerbook(running Tiger). I went to the link and followed the instructions and it worked. Did i mention that my dad who has a iMac running Leopard now has the same problem. I thought i would just do the same but the Preference in Mail for Leopard is of course different. There is no icon called "Server Settings" under Accounts section like there is on mine. Do you have a link for the same kind of instructions for Leopard?
    Thanks again,
    Bryce

Maybe you are looking for

  • How to insert decimal point while selecting data from a table

    Hi All , My select requirement says , If the value received with no decimal then insert decimal before last 2 bytes. I need to retrieve data with this condition. May you people help how i can achieve this? Thanks in advance, Sachetan

  • Is there any limit on how many records a cursor can hold?

    Hi Everyone, This is Amit here. I want to know whether there is any limit on how many records a cursor can hold. I have a program in which i am creating a cursor and passing it to another procedure as an input parameter. But the count of cursor query

  • QT player won't play in third display

    I have two GeForge 7300 GT display cards in MacPro and only 1 card dispalys QT palyer correctly. I have tried all combinations of slots and speeds. All displays play correctly in other programs like FCP, Eyetv, etc. Any ideas?

  • Help For selection screen

    Hi, I dont have any selection screen in my program. But when user press enter the transaction he should get  some screen in which some message is written" This pgm is for background". Plese suggest me.

  • Citrix getting port in use message.

    I am getting message when trying to connect to citrix. It says port 999 already in use. How can I tell what ports are in use?