Problems with where rownum = 2, but not rownum = 1.

Can anyone explain to me why I get the expected result when I do
rownum = 1
rownum <= 2
rownum < 3
but not for
rownum > 1
rownum = 2
SQL> create table test(a number, b number);
Table created.
SQL> insert into test VALUES(1,2);
1 row created.
SQL> insert into test VALUES(2,3);
1 row created.
SQL> select rownum, a, b from (select a,b from test where a < 10 order by b desc);
ROWNUM A B
1 2 3
2 1 2
SQL> select rownum, a, b from (select a,b from test where a < 10 order by b desc) where rownum = 1;
ROWNUM A B
1 2 3
SQL> select rownum, a, b from (select a,b from test where a < 10 order by b desc) where rownum > 1;
no rows selected
SQL> select rownum, a, b from (select a,b from test where a < 10 order by b desc) where rownum = 2;
no rows selected
SQL> select rownum, a, b from (select a,b from test where a < 10 order by b desc) where rownum <= 2;
ROWNUM A B
1 2 3
2 1 2
SQL> select rownum, a, b from (select a,b from test where a < 10 order by b desc) where rownum < 3;
ROWNUM A B
1 2 3
2 1 2
SQL>

ROWNUM is only incremented when a record passes the WHERE clause (but ROWNUM is assigned before the rows are ordered).
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/pseudocolumns009.htm#i1006297
So if you need to use a lower bound for ROWNUM, you must use a subquery. And as you usually need first/second/third record when sorting by field x, there will be two levels of subqueries.
SELECT *
FROM (SELECT *, rownum rn
FROM (SELECT ...your query... ORDER BY x)
WHERE rownum<=2
WHERE rn=2

Similar Messages

  • TS3297 Why I can't download a free game I get a message that there's a problem with my payment method but not what it is this is a free app I tried support and got nowhere help

    Why can't I down load a free app  I get a message that there is a problem with my payment method but I gave all information correctly , I did recently change my card no because I lost my old one .i did change the no. On my account      HOPE YOU HAVE SOME SUGGESTIONS  I DON'T SEE WHY THEY HAVE TO CHECKMY PAYMENT METHOD FOR A FREE GAME

    Contact iTunes customer support.
    We're all users like yourself and as such have no access to your account.

  • Problem with .sitx files (Safari but not Firefox???)

    Hi All,
    I have a website online (with help from iWeb and BBEdit) but am having a problem I cant figure out (this IS my first website!)
    I am hoping that someone much more knowledgeable than me can help me with it.
    I basically have a download section. Icons and desktops.
    Now, when I (or anyone else) tries to download- everything seems to be fine in FireFox (even IE!) but not in Safari.
    My desktops are compressed as .zip files. No problems there, everyone can download and open (including Safari users!)
    My icons are compressed as .sitx files. This is where the problems come in. Firefox and IE download them no problem ('save to disk?' etc) However when one attempts to download the icons (.sitx files) with Safari it simply displays pages of gibberish (starting with the word 'Stuffit') which I am presuming is Safari trying to 'display' the contents of the actual stuffit file.
    Why is this? Why wont safari simply download the .sitx files as it does .zip files?
    Does Safari have some sort of inherent problem with .sitx files? Is it some sort of configuration within Safari preferences? or (and probably most likely!) is it something I have done wrong?
    Oh, my website (page in question!) can be found here:
    http://aoimedia.co.uk/news/news.html
    Thanks in advance for all your valuable help
    Kind regards
    John
    12 G4 Powerbook/Superdrive. (she's named Skates!) Mac OS X (10.4.4)

    Hi,
    It sounds like the server the website/file is hosted on is not identifying the type correctly. As you've seen, different browsers will handle this situation differently.
    Have a read of this article:
    http://www.macosxhints.com/article.php?story=20040211102018600
    Hope that helps.

  • InDesign CS5 causing problems with InCopy assignment file but not content files

    I'm having a strange InDesign/InCopy CS5 issue (Mac OSX 10.6.6; all system & Adobe updates are current).  In my InDesign doc I have one assignment file containing two content files. All of the InCopy pieces work fine in InDesign (i.e., I can check out/in, edit, etc.).  When I go to open the assignment file in InCopy, InCopy starts to open  it but then crashes. If I try to open each content file directly in  InCopy, no problem. I've tried deleting and recreating new assignments  in InDesign, but they all have the same result in InCopy.
    I think this actually is a problem with the InDesign file because if I export the InDesign file to IDML, then try to open the IDML file, InDesign crashes! I've trashed my InDesign preferences, made sure all cross-references are up to date, etc. Anybody have any ideas what else to look for in my InDesign file that might cause this problem?
    Thanks!
    Andrea

    Thanks John!
    1) Here are the first 10-ish lines from the crash report that is generated when I try to open the IDML file:
    Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
    0   ???                               0xa0c266f0 _XHNDL_trapback_instruction + 0
    1   com.adobe.InDesign.Indexing       0x20778192 GetPlugIn + 341394
    2   com.adobe.InDesign.Indexing       0x20779009 GetPlugIn + 345097
    3   PublicLib.dylib                   0x0129228b CScriptProvider::AccessProperties(IScriptRequestData*, IScript*) + 571
    4   com.adobe.InDesign.Scripting      0x1f4befe8 GetPlugIn + 166440
    5   com.adobe.InDesign.Scripting      0x1f4c2e31 GetPlugIn + 182385
    6   com.adobe.InDesign.INXCore        0x20641444 GetPlugIn + 45220
    7   PublicLib.dylib                   0x0142c9e8 CScriptDOMElement::GetMultipleAttributes(K2Vector<IDType<ScriptID_tag>, K2Allocator<IDType<ScriptID_tag> > > const&, adobe::version_1::vector<KeyValuePair<IDType<ScriptID_tag>, DOMAttributeValue>, adobe::version_1::capture_allocator<KeyValuePair<IDType<ScriptID_tag>, DOMAttributeValue> > >&) + 280
    8   PublicLib.dylib                   0x0142bd38 CScriptDOMElement::InsertProperties(adobe::version_1::vector<KeyValuePair<IDType<ScriptID _tag>, ScriptData>, adobe::version_1::capture_allocator<KeyValuePair<IDType<ScriptID_tag>, ScriptData> > >&, adobe::version_1::vector<KeyValuePair<IDType<ScriptID_tag>, DOMAttributeValue>, adobe::version_1::capture_allocator<KeyValuePair<IDType<ScriptID_tag>, DOMAttributeValue> > > const&, short, short) + 1336
    9   PublicLib.dylib                   0x0142beab CScriptDOMElement::SetSimpleAttributes(adobe::version_1::vector<KeyValuePair<IDType<Scrip tID_tag>, DOMAttributeValue>, adobe::version_1::capture_allocator<KeyValuePair<IDType<ScriptID_tag>, DOMAttributeValue> > > const&, short) + 91
    10  PublicLib.dylib                   0x0142c0d3 CScriptDOMElement::SetAttributes(adobe::version_1::vector<KeyValuePair<IDType<ScriptID_ta g>, DOMAttributeValue>, adobe::version_1::capture_allocator<KeyValuePair<IDType<ScriptID_tag>, DOMAttributeValue> > > const&) + 51
    11  PublicLib.dylib                   0x0142a2ea CScriptDOMElement::SetAttribute(IDType<ScriptID_tag>, DOMAttributeValue const&) + 202
    2) That works. Moved all pages (frame threading was preserved) to a new doc, exported to IDML, opened new IDML file just fine. Woo hoo! One of my editors won't be pleased that all of the tracked changes have disappeared, but at least the file functions now
    Wish I knew what caused the problem in the first place so we could (hopefully) prevent this from happening again. Any ideas?
    Thanks again for your help!
    Cheers,
    Andrea

  • Various audio problems with the onboard speakers but not the headphones​.

    The little volume wheel is connected to a variable resistor, which is soldered to the motherboard via 7 pins.  when the wheel loosens up, or the pins loosen up, the onboard speakers get flaky or just don't work.  We've been seeing this type of problem for a while now, and just thought that the general public should know.  Either replace the motherboard, or the volume controller, or wiggle and jiggle the wheel when it gives problems.  good luck all, and i hope this little tid-bit helps out.
    Kudos for Linux and all freeware!!

    Hi,
    Try the following.
    First, download and reinstall the Chipset driver on the following link.
    Chipset Driver - Windows 8
    When the reinstallation has completed, restart the notebook.
    When windows has reloaded, download the IDT Audio installer on the link below and save it to your Downloads folder.
    IDT Audio Installer - Windows 8.
    When done, open windows Control Panel, open Device Manager and open up Sound, Video and Game Controllers.  Right click the IDT device and select Uninstall - you should also get a prompt to remove the current driver, tick the box to allow this and then proceed with the uninstall.
    When complete, shut down the notebook, unplug the AC Adapter and then remove the battery.  Hold  down the Power button for 30 seconds.  Re-insert the battery and plug in the AC Adapter.
    Tap away at the esc key as you start the notebook to launch the Start-up Menu and then select f10 to enter the bios menu.  Press f5 to load the defaults ( this is sometimes f9, but the menu at the bottom will show the correct key ), use the arrow keys to select 'Yes' and hit enter.  Press f10 to save the setting and again use the arrow keys to select 'Yes' and hit enter.
    Let Windows fully load - it will automatically load an audio driver, but just let this complete.  Then open your Downloads folder, right click on the IDT installer and select 'Run as Administrator' to start the installation.  When this has completed, right click the speaker icon in the Taskbar and select Playback Devices.  Left click 'Speakers and Headphones' once to highlight it and then click the Set Default button - check if you now have audio through headphones.
    Regards,
    DP-K
    ****Click the White thumb to say thanks****
    ****Please mark Accept As Solution if it solves your problem****
    ****I don't work for HP****
    Microsoft MVP - Windows Experience

  • I am trying to set up iTunes match on my apple tv, but it just keeps showing that it is loading, it has been running for over an hour, what can be done here, it has gone with no problem on my iPhone, iPad but not the tv

    i am trying to set up iTunes match on my apple tv, but it just keeps showing that it is loading, it has been running for over an hour, what can be done here, it has gone with no problem on my iPhone, iPad but not the tv

    Same here and this is driving me crazy. I can buy, but can't upgrade. Grrr.

  • I installed Adobe CS6 Design & Web Premium on my Mac Book Pro a few years ago but have repeatedly encountered problems with the programs freezing or not opening properly. It's a Student and Teacher Licensing version so an academic ID is required but I am

    I installed Adobe CS6 Design & Web Premium on my Mac Book Pro a few years ago but have repeatedly encountered problems with the programs freezing or not opening properly. It's a Student and Teacher Licensing version so an academic ID is required but I am no longer a student--can I still reinstall it since my academic ID may no longer be valid?

    Erin Elzo as long as the serial number has been registered under your account at http://www.adobe.com/ then you should be able to continue to utilize the software.  You can find details on how to locate your registered serial number at Find your serial number quickly - http://helpx.adobe.com/x-productkb/global/find-serial-number.html.

  • I fixed the problem with the whole 'waiting' and not loading but now some of my apps won't open, what can I do?

    I fixed the problem with the whole 'waiting' and not loading but now some of my apps won't open, what can I do?

    - Try a reset. Nothing is lost
    Reset iPod touch: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Purchase/install any new app
    - Try the remaining items of:
    iOS: Troubleshooting applications purchased from the App Store

  • I have I.O.S. 6.0.1 and i live in Georgia, Tbilisi. I have got the problem with maps. It does not get directions. Per exemple it was working in italy but in my cuntry it does not work. Could u explain me what can i do to make my maps work in Georgia?

    I have I.O.S. 6.0.1 and i live in Georgia, Tbilisi. I have got the problem with maps. It does not get directions. Per exemple it was working in italy but in my cuntry it does not work. Could u explain me what can i do to make my maps work in Georgia?
    Thank u

    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    *Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Tools > Options > Privacy > Cookies: "Show Cookies"

  • Hello i have a problem with onfocus function on ipad. i am trying to bring my cursor on a text box on a button click. It works fine with safari web browser but not on ipad. Need a solution.

    Hello i have a problem with onfocus function on ipad. I am trying to bring my cursor on a text box on a button click. It works fine with safari web browser but not on ipad. Need a solution.

    I don't think that a software update from Apple will solve the issues that you are having. You have a rogue installation. After you posted I have just done the following:
    Disk Utility can verify  my partitioned Volume (including my boot disk) AND REPAIR the non-boot disks on the same Volume without a glitch. It repairs the non-boot disks containing data smoothly.
    I have used Mail to send some mails from some Yahoo and Hotmail accounts to my Thunderbird client containing GMail accounts - absolutely normal.
    I have iLife '09 but my iMovie '09 and iPhoto '09 open in a jiffy and I see no issues here. I have 6GB RAM (Maximum) on an early 2008 Macbook Pro with a 750GB hard drive partitioned with 120GB reserved for the Boot Drive.
    I am sorry that I cannot help further but I am sure there must be a way to reinstall the software without having to revert to restoring your ML backup. I have two clones and if you have such I would attempt to do that through that rather than through Time Machine - that is of course if you have a cloned drive.
    Good luck!

  • Hello, I have problems with iCloud. I do not recognize the password and can neither a reset occurs every time I want to do something to stick to iCloud password but does not recognize, what to do? thank you

    Hello, I have problems with iCloud. I do not recognize the password and can neither a reset occurs every time I want to do something to stick to iCloud password but does not recognize, what to do? thank you

    Stop multiple posting

  • IPod nano works with USB 1.1 but not USB 2.0

    Anyone using an iPod nano that works with USB 1.1 but not with USB 2.0? I am using Windows XP and when installing the iPod software from CD it recognizes the iPod and am able to transfer songs using iTunes but when installing SP1 or SP2 to enable USB 2.0 transfers, Windows XP only recognizes the iPod nano as a USB Mass Storage Device. This is the same with iPod Updater.

    I have a similar problem with the following configuration:
    - Dell Dimension 4100 Desktop with 2 integrated USB 1.1 ports, Windows 2000 SP 4
    - PCI 6-Ports USB 2.0 Card ("Mentor" resp. www.bona.com.tw), Model USB20-PCI/6P
    What works well?
    - All my USB add-ons (1.1 and 2.0) on the internal 1.1 ports as well as on the USB2.0 PCI card
    - iPod Nano 4GB on internal 1.1 ports (external drive in windows 2000 as well as iPod in iTunes)
    - iPod Nano works as well as on the USB 2.0 card ONLY WHEN my old 4-port USB1.1 hub is connected between Nano and USB card
    What doesn't works?
    My iPod Nano directly connected to the USB 2.0 card. Symptoms when connecting:
    - Windows is very slow, process "scvhost.exe" or "system.exe" using 99% of CPU for some minutes
    - iPod is recognised as external drive, but when I click on it, it is empty and copying files to it results in "I/O error"
    - iTunes doesn't recognise the iPod (of course, if even windows itself cannot read from it...)
    I removed all USB drivers, reinstalled iTunes, iPod (by the way, I still don't understand what "iPod update" is good for, except for updating the iPod's firmware), deactivate the internal USB1.1 ports, no result.
    Help!!!!!!!!!!!!!!!!

  • I have an iPhone 4S and never had a problem with syncing it. But suddenly, when I connected my phone to my mac, it says that its in recovery mode, and I need to restore it in order to sync. I've updated both my phone and my itunes, and it didnt work.Help?

    I have an iPhone 4S and never had a problem with syncing it. But suddenly, when I connected my phone to my mac, it says that its in recovery mode, and I need to restore it in order to sync. I've updated both my phone and my itunes, and it didnt work.Help?

    fighter19lisa wrote:
    that only makes it say its synced, when its not.
    No, it does not.  It transfers purchases from the iDevice to the computer.  The computer must be authorized for the Apple ID that the content was acquired with.
    fighter19lisa wrote:
    my playlists wont show up on the phone.
    Are they selected to sync?  Is Manually Manage content on the device selected?
    fighter19lisa wrote:
    i had to change my password for my aol account again and i still cannot get my email on my phone to even work
    What does that have to do with syncing content to the device?  FYI, nothing.

  • I have big problems with mountain lion. you can not have a boot disk system I resulted in the need to re-download the os from scratch impiegandoci 8 hours, it is outrageous even with windows 95.

    I have big problems with mountain lion. you can not have a boot disk system I resulted in the need to re-download the os from scratch impiegandoci 8 hours, it is outrageous even with windows 95.
    at least that the operator has confirmed to me that he called me. I also have problems with either the start of the mac with the power off. I can not understand if it crashes or is just very very slow.
    Finally, I have a problem with the external hard disck. I often said to have been ejected incorrectly (not true) and I start to restore the startup recovery disk because disk utility is ineffective from the normal operating system .. is a shocking thing, but how you reduced. in four years it had never happened. seem to have windows or worse. Wake up.
    I am an Italian, alas, and then I would like an answer to my language because my € are the same as German French or English.

    You are on Windows 2000, you do not have a "Firefox" button, and should consider yourself to be fortunate in that you still have menus and don't have to do anything to get the menus back instead of the "Firefox" button. (The same applies to Windows XP users).
    Use the "File" menu to get to Import. You are not on Windows 7 or Vista, and don't have to put up with the nonsense added for Aero.
    If you want the "Firefox" button you can get it with View -> toolbars -> (uncheck) Menu Bar. The menu bar and the "Firefox" button were supposed to be mutually exclusive (which is impossible in some cases without being incompatible).
    Once you are using the "Firefox" button ...
    Use the "Alt" key to view the menu bar (temporarily) containing File, Edit, View, History, Bookmarks, Tools, and Help. On Windows 7 and Vista, the menu bar was hidden by default in Firefox 4 and above. These menu items are more or less available under the "Firefox" button which has the most used of the built-in Firefox menu items available in a different format.
    To get back to having menus again. "Firefox" button -> Options (second column) -> (check) Menu Bar
    You can make '''Firefox 7.0.1''' look like Firefox 3.6.*, see numbered '''items 1-10''' in the following topic [http://dmcritchie.mvps.org/firefox/firefox-problems.htm#fx4interface Fix Firefox 4.0 toolbar user interface, problems (Make Firefox 4.0 thru 8.0, look like 3.6)]. ''Whether or not you make changes, you should be aware of what has changed and what you have to do to use changed or missing features.''
    * http://dmcritchie.mvps.org/firefox/firefox-problems.htm#fx4interface

  • [Execute SQL Task] Error: Executing the query "DECLARE_@XMLA nvarchar(3000) ,__@DateSerial nvarch..." failed with the following error: "Incorrect syntax near '-'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly,

    Hi
    DECLARE @XMLA nvarchar(3000)
    , @DateSerial nvarchar(35);
    -- Change date to format YYYYMMDDHHMMSS
    SET @DateSerial = CAST(GETDATE() AS DATE);
    --SELECT @DateSerial
    Set @XMLA = 
    N' <Batch xmlns="http://schemas.microsoft.com/analysis services/2003/engine">
     <ErrorConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2"
    xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2" xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100" xmlns:ddl200="http://schemas.microsoft.com/analysisservices/2010/engine/200"
    xmlns:ddl200_200="http://schemas.microsoft.com/analysisservices/2010/engine/200/200">
    <KeyErrorLimit>-1</KeyErrorLimit>
    <KeyNotFound>IgnoreError</KeyNotFound>
    <NullKeyNotAllowed>IgnoreError</NullKeyNotAllowed>
     </ErrorConfiguration>
     <Parallel>
    <Process xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2" xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2"
    xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100" xmlns:ddl200="http://schemas.microsoft.com/analysisservices/2010/engine/200" xmlns:ddl200_200="http://schemas.microsoft.com/analysisservices/2010/engine/200/200"
    xmlns:ddl300="http://schemas.microsoft.com/analysisservices/2011/engine/300" xmlns:ddl300_300="http://schemas.microsoft.com/analysisservices/2011/engine/300/300">
     <Object>
     <DatabaseID>MultidimensionalProject5</DatabaseID>
     <CubeID>giri</CubeID>
     <MeasureGroupID>Fact Internet Sales</MeasureGroupID>
     </Object>
     <Type>ProcessFull</Type>
     <WriteBackTableCreation>UseExisting</WriteBackTableCreation>
     </Process>
      </Parallel>
    </Batch>';
    EXEC (@XMLA) At SHALL-PCAdventureWorksDw ;
     iam executive the    query when iam getting below error.
      [Execute SQL Task] Error: Executing the query "DECLARE
    @XMLA nvarchar(3000)
    , @DateSerial nvarch..." failed with the following error: "Incorrect syntax near '-'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set
    correctly, or connection not established correctly. 
     how to solve this error;
     please help me

    What are you trying to do? What sort of data source is  SHALL-PCAdventureWorksDw?
    When you use EXEC() AT, I would execpt to see an SQL string to be passed to EXEC(), but you are passing an XML string????
    If you explain why you think this would work in the first place, maybe we can help you.
    Erland Sommarskog, SQL Server MVP, [email protected]

Maybe you are looking for

  • Can i force a officejet pro 8000 a809 to print black and white when a color cartrigde is empty?

    I am trying to get two text document printed and I get an No ink/toner message on the top the printer que window. It is the Yellow ink cartridge, can I bypass this and force it to print in black and white only?

  • Smartview: shared members on level o has a prefix of level 1

    Hi, I'm using smartview 11.1.2.3. I have a dimension with multiple parallel hierarchies: level1a->level0, level1b->level0, level1c->level0, as a result the level 0 members which apears below level1b and level1c are shared members. when I'm "zooming i

  • Workstation cann't run .asp on IIS after installed ZEN agent

    Hello, I have Windows XP sp2 on workstation. I run .asp application on IIS. When i installed Zenwork Desktop Agent (6.5). I cann't run .asp file. I reinstall IIS on workstation. It's not work. thank you moo

  • No search results found

    Hello, I have created an index with index service Portal Roles Search & set the datasource as well. But the search result is returning nothing though i give a valid document. The crawler  is set to standard. Any ideas? Regards, Rukmani

  • Running GB 1.1 on Intel-based cpu

    I'd like to know if there will be any problem running GB 1.1 on an Intel-based Mac. I need to do this for my school music classroom, as all the computers there use that version on eMacs. All help will be appreciated.