Rownum works only where rownum = 1

Hello
I have a query that will return the 2 rows:
SQL> select start_date
  2  from employees join job_history using (employee_id)
  3  where employee_id = 2168
  4  order by start_date desc;
 
START_DATE
-----------
01/04/2004
02/03/2003
I wanted to have the first line in this result, so I used rownum and it worked:
SQL> select x.start_date
  2       from (select start_date
  3             from employees join job_history using (employee_id)
  4             where employee_id = '2168'
  5             order by start_date desc) x -- the first row will be the latest start_date
  6       where rownum = 1;
 
START_DATE
-----------
01/04/2004
But when I wanted to get the number of line 2, it returns null:
SQL> select x.start_date
  2       from (select start_date
  3             from employees join job_history using (employee_id)
  4             where employee_id = '2168'
  5             order by start_date desc) x -- the first row will be the latest start_date
  6       where rownum = 2;
 
START_DATE
-----------
Why is this?
Thank you

Rownum is applied to the result that the records are returned. So the first record in the result set always has {make: courier new} rownum = 1 {font}. If {make: courier new} rownum = 2 {font} can never be true. This is a discussed [url http://docs.oracle.com/cd/B19306_01/server.102/b14200/pseudocolumns009.htm#i1006297] in the SQL manual.

It is an old chestnut and the solutions are easily detectable, but they all involve using a nested query to a description.

select * from
    ( select t.*, rownum as rn
      from your_table t
    )
where rn = 2;

To have a sorted result set you need two layers of nesting:

select * from
    ( select t.*, rownum as rn
      from
        (  select * your_table
          order by whatever
        ) t
    )
where rn = 2;

Cheers, APC

Tags: Database

Similar Questions

  • I got Pro 8.0 on an old computer.  tried to install pto 8.1 using only series. as old and it did not work.  where can I find pro 8.0 or where can I find the correct SN?

    I got Pro 8.0 on an old computer.  tried to install pto 8.1 using only series. as old and it did not work.  where can I find pro 8.0 or where can I find the correct SN?

    If you do not need acrobat 8 pro or something another link below, you will need to explain.


    Available downloadable Setup files:

    Download and installation help links Adobe

    Download and installation to Prodesigntools help links are located on the most linked pages.  They are essential; especially steps 1, 2 and 3.  If you click on a link that does not have these listed steps, open a second window by using the link to Lightroom 3 to see these "important Instructions". window using the Lightroom 3 link to see these "important Instructions".

  • I have the code for an Adobe Creative Cloud, it is alphanumeric, but the registry works only with numeric codes ¿where I can use my code?

    Hi, I have a problem with code for my Adobe Creative cloud, it is alphanumeric, but the registry works only with numeric codes ¿where I can use my code? is a subscription to creative cloud of throughout the year.

    Probably you have a redemption code... especially if you did not purchase directly from Adobe

    Redemption Code http://helpx.adobe.com/x-productkb/global/redemption-code-help.html

    -or https://forums.adobe.com/thread/1572504

  • My program works only in debug mode

    Dear all,

    I'm just starting to use LabVIEW and develop a pilot thing.

    The program is rather in order because I only used to work with text-based program.

    The current program works without any error message from debug mode.

    To give an idea of how it is made:

    1. configure the serial port settings (address of the machine, baud rate, parity, etc.)

    2. send to the instument the name of a short to run program.

    3 send commands of mutiple string instruments.  These channel commands build a short program to control the instrument.

    4 send another command string to run the short program

    The problem is that it does not work in enforcement mode.  It seems to me that the communication between the device and the computer seems to be too fast.

    Given that the program is designed in a sequential manner, not have a loop while or do loop so I can not add any timing function.

    Could someone give me a tip or a good direction for this problem?  It would be really appreciated.  Thank you.

    You could do something like the amendment attached. Note how I modified the component of connector for the Subvi in the classic 4-2-2-4 operating mode and notice where I connected the terminals.

    NOTE: I guess that the VI is supposed to work only once, and that you do not use the continuous run button in the toolbar. You're not, are you?

  • Hi all. How can I manage the preferences that LR do not take up space on my MAC hard drive and works only on the external hard drive?

    Hi all. I am new and on a free trial right now.

    How can I manage the preferences that LR do not take up space on my MAC hard drive and works only on the external hard drive?

    Monthly payment included cloud storage?

    Peut I manage backups? And how?


    -Amir

    Hi amireos,

    Yes, you can create your workflow where you can keep all your images on the external hard drive and the Lightroom catalog file as well.

    If you start with Lightroom and then use the Destination location as external hard drive when you import your image of the external source such as a camera or SD.

    If you already have your Images on the Mac HD drive, then play all your Image on the external hard drive first and then import images directly from there.

    Finally, you can change the location of the Lightroom Catalog as well.

    Default location: folder on the Mac Drive HD, there is folder called Lightroom that you can move on the external drive too (however catalog Lightroom can't memory space as its only import previews of the images is not the real image and full)

    Once you move the file catalog Lightroom external hard disk, then you need to browse the catalog file when you launch Lightroom only once.

    See thread: LR catalog moving on external hard drive

    Let us know if it helps.

    Kind regards

    ~ Mohit

  • Advanced search works only with verification of the equality of the sexes

    Hi all

    I don't know if this is something you can help me or if I'm missing something completely obvious.

    I have a 'advanced search form' which has a few options to check through for example age, city, nationality, etc. and I have two sets of records, one for the user who has the gender are stored in $SameGenderCheck

    And I have a SQL query for the search criteria for the search form.

    Here's the SQL statement:

    $query_search_res = "SELECT * FROM profiles LEFT JOIN profile_details ON profiles.profile_id = profile_details.profile_id WHERE (city = '$location') OR (ethnicity = '$ethnicity' OR nationality = '$nationality' OR marital_history = '$marital_history' OR height = '$height') AND (Age BETWEEN '$age_from' AND '$age_to') AND (gender != '$SameGenderCheck') AND (approved = 'Yes')";
    

    Thank you.

    > other search options are optional, so if they are entered, they will reduce more

    > down search results if they are not then simply use age and city.

    Okay, I think that it is actually the part that is causing problems for you. You want that all the criteria to NARROW your results.  You want to ethnicity, nationality, marital_history and the height to be optional criteria, so you have combined with the rest of the statement with a RC. But an OR condition will always expand results, not close. If you must change the first residence in one and. GOLD is used within the jurisdiction parens for these criteria are OK.

    $query_search_res = "SELECT * PROFILES LEFT JOIN profile_details ON profiles.profile_id = profile_details.profile_id WHERE (city ="$location") AND (ethnicity = nationality GOLD" $ethnicity"="$nationality"marital_history ="$marital_history"height GOLD GOLD ="$height") AND (age BETWEEN '$age_from' AND '$age_to') AND (sex!» (= «$SameGenderCheck») AND (approved = "Yes");

    But here's the problem; If the user has no entry for ethnic origin, nationality, the marital_history and the height of the criteria, no results will be returned. Regular SQL will not solve your problem. You can work around the problem by replacing the equality by the LIKE predicate operator and put a wildcard for users who do not have that criterion in their profile. But that works only for text fields, not digital, and I don't like.

    A better solution is to dynamically create the WHERE clause, remove the criteria of ethnicity, nationality, marital_history and the height of the WHERE clause if the user does not have these fields completed.

  • My button function seems to work only once

    When I say Flash back executives that the buttons stop working, in other words, the button works only once. I tried to trace to find the problem and when I say to return images it won't function.  I use the Flash CS4 actionscript 3.

    hap.addEventListener (MouseEvent.CLICK, clickFunction2);
    trace ("addEventListener worked!");
    function clickFunction2(evt:MouseEvent):void {}
    trace ("clickFunction2 worked!");
    this.gotoAndPlay (191);
    trace ("gotoAndPlay worked!");
    }

    sad.addEventListener (MouseEvent.CLICK, clickFunction3);
    trace ("addEventListener worked!");
    function clickFunction3(evt:MouseEvent):void {}
    trace ("clickFunction3 worked!");
    this.gotoAndPlay(1,"sadness");
    trace ("gotoAndPlay worked!");
    }

    ang.addEventListener (MouseEvent.CLICK, clickFunction4);
    trace ("addEventListener worked!");
    function clickFunction4(evt:MouseEvent):void {}
    trace ("clickFunction4 worked!");
    this.gotoAndPlay(1,"anger");
    trace ("gotoAndPlay worked!");
    }

    rewind.addEventListener (MouseEvent.CLICK, clickFunction5);
    trace ("addEventListener worked!");
    function clickFunction5(evt:MouseEvent):void {}
    trace ("clickFunction5 worked!");
    this.gotoAndPlay(120,"happiness");
    trace ("gotoAndPlay worked!");
    }

    your buttons probably don't exist when you edit images.

    to remedy this, do not use the timeline to eliminate your pimples.  removeChild() to remove them when you change pictures and when you return to the frame where you want your buttons to appear, use addChild().

  • mini presentation remote mac works only sporadically

    Hi all

    I have a Logitech R400 that needs to be able to control the PowerPoint on a Mac mini.

    Yesterday it worked fine.

    Today, he works only sporadically, and I have not changed a thing. It's still the same presentation.

    Sometimes, you can change the slide and sometimes you can't (even when standing very close to the Mac mini).

    This Mac mini specifications are quite anemic (1.4 GHz and 4 GB of memory), but I closed all applications except PowerPoint and have nearly 2 GB of free memory.

    Any thoughts?

    Any help would be most appreciated!

    Mike

    Based on

    http://www.Logitech.com/en-us/product/Wireless-Presenter-R400

    the remote uses a USB wifi dongle and operates on the 2.4 GHz band.

    This band is susceptible to interference and I think that is causing your problem.

    Peripheral USB 3 is a source of interference.

    Try to use the dongle at the end of an extension USB cable

  • Modules of working only once

    It has been some time now that I noticed my addons not working not not on Mozilla TO in Ubuntu. Addons are installed properly and, indeed, they appear when I use mozilla sync in other computers.

    Today I tried the suggested troubleshooting here https://support.mozilla.org/en-US/questions/982460
    It works only once. I can install my addons again, but as soon as I close firefox and reopen the addons disappear from the top bar and the customization window. Even when I try to change preferences for Ghostery I get only blank a screen so addons are absolutely not working in Ubuntu

    Note that the OP is using the developer edition (39 Firefox) and not the regular version.

    Have you checked for problems caused by one or more of the extensions that may not be fully compatible with OF?

    Create a new profile as a test to see if your profile is the source of the problem.

    See "create a profile":

    If the new profile works then you can transfer files from a profile already used in the new profile, but be careful not to copy files corrupted to avoid transporting more problems.

  • My USB to ethernet adapter works only if plugged into my MacBook Pro. I tried to use to start an expander USB (power strip), but this has not--a problem when you have only TWO USB ports ports! Any suggestions?

    My USB to ethernet adapter works only if plugged into my MacBook Pro.

    I tried to use to start an expander USB (power strip), but this has not--a problem when you have only TWO USB ports ports!

    Any suggestions?

    Juice what 'expander' did you use?

    What model of MacBook Pro?

    This is the Office Mac Pro forum. I asked that your post be moved to the MacBook Pro laptop forum.

  • RoboForm does not work with your new browser. It is very fustrating and works only with Windows Explorer. I need to reinstall the old FIREFOX program?

    RoboForm does not work with your new browser. It is very fustrating and works only with Windows Explorer. I need to reinstall the old FIREFOX program?

    RoboForm has already released a version with support for the latest version of Firefox. See http://www.roboform.com/support/news. Try upgrading to the latest version of Roboform.

  • CPU works only 30-40% on Satellite A200

    On my Toshiba Satellite A200-10w psaece I was running like a lot of antivirus programs, music player, web browser, photo programs as well as the transformer works only 30-40%.

    Someone knows why? It's a solution?

    I have all the updated drivers, include the bios.

    Thank you

    Are you sure you knew what you're talking about?
    I think you don t know how a CPU Intel Core 2 Duo T7200(2.0GHz) work.

    The fact is that this processor supports Enhanced Intel SpeedStep technology and this is the main reason why you CPU doesn t ALWAYS better performance running.

    Maybe you should check the Intel page for more details and for more information on Enhanced Intel SpeedStep Technology, if this feature is not known to you!

    Welcome mate

  • Satellite A130: Fn key not working only not with Vista - only FlashCards

    Hello

    I've been looking around in the forums, but I couldn't find solutions to my problem.

    I have a satellite A130 and I am running a windows VISTA family Basic. I have a problem with my fn functions.
    I can only use flash on the top of my screen cards, just by dragging my mouse upwards on the top of my screen.

    The key works only when I start my computer, at startup, but when the computer is running, there is no other "fn", I could use but my mouse to show my flash cards and use them.

    Is there something else I could do?
    Thank you

    I have same situation, remove the starting windows for the form Flash cards and you have no pictures at the top of the desctop, but keys will work.

  • Equium A110-233 stops using the WiFi and the fans work only 3 sec

    I bought an A110 - 233 20/09/06. It works very well for about 1 hour then it interrupts the communication via the wireless network connection status States he is always connected, sometimes but not always the configuration window indicates that the without wire is cut and I should turn it on at the bottom of the window (there is lit) processor Intel Pro.

    I brought the world PC waiting for a replacement but I had to sit for an hour trying to reproduce the error, we couldn't go wrong but I have discovered that it does only when running on the network.

    Cooling fan only works for 1-3 seconds at a time, is it possible to increase this number.

    Any help would be appreciated
    Bob

    Hello

    If you want to change the properties of cooling module you must do in the standby power settings.
    You should know that the energy saver uses different modes of consumption. The laptop is using another mode of energy if the AC adapter is plugged and another mode of power if the laptop works only with the battery.
    On the basis of energy saver menu, you will be able to change the method of cooling. This option controls the fan.

    It is not easy to solve the problem of WLAN communication. I mean that there is no general solution. Additional it is not easy to solve because the issue doesn't happen always, but sometimes only. Perhaps the intensity of the signal is sometimes lower and therefore, the configuration software WLan Intel reports that the wireless network is turned off.

    In addition, you should also check the Wlan card properties. You will find that the properties in Device Manager-> right click on the wireless network card.
    Here, you must select the Advanced tab.
    You should find a few interesting options such as energy saving (disable) or the strength of the signal (enable).

    In addition, you can try to update the WLan driver. Maybe a new version is available.

    By the way: you should also know that some 3rd party application could have a bad influence on WLan communication.

  • Lenovo Vibe X 3 works only if the prosecution so disconnected it out

    Hi my Lenovo Vibe X 3 works only when it is connected to the charger, so disconnected mobile switches off the coast. I took it to the service center and it's under warranty they replaced the battery free of cost. But the problem persists. Please suggest any help is very appreciated.

    Back to the service center to let them check again. Get the receipt of service that you received the last time you went there.

Maybe you are looking for