Sorting with Name

hi
i have procedure with sorting technic..
for sorting i have used code like this
......select ...... .. select ......  rownum rn from table_name
                         where cond...
         where pagenumber ......  pagesize........
but now i want display result according to sorting,
with alphabetic sorting.
means if a user want to search name like start with name "M"
i want to display result with starting letter is "M" as follows...
and also user want to move <<next> <<last>> <<first>> <previouse>>for this any doc's or sample example or any ideas
Edited by: OraclePLSQL on Dec 30, 2010 5:31 PM

Hi,
ROWNUM shows the order in which a row was received.
If the source of the data is a table, then the order is undefined, and ROWNUM is arbitrary.
If the source of the data is a sub-query or a view, then ROWNUM reflects the ORDER BY clause of that sub-query or view. If there is no ORDER BY clause, then ROWNUM is arbitrarty.
If you want a Pagination Query , where you each page has a given size (it looks like 3 in your example), and you want to display only one given page (page #2 in your example), then you can use ROWNUM, but assign ROWNUM after the data is ordered.
So you could modify the query you posted like this:
SELECT * FROM
   SELECT ENAME,    EMPNO,    SAL
   ,      ROWNUM   AS RN               -- ROWNUM is meaningful here (source is ordered)
   FROM
     SELECT    ENAME, EMPNO, SAL          -- No ROWNUM here (source is not ordered)
     FROM      EMP
--   WHERE     ename     LIKE 'M%'          -- Any filtering goes here
     ORDER BY  ename
   WHERE ROWNUM <((2*3)+1)
WHERE RN >= (((2-1)*3)+1)
ORDER BY  rn
;Remember to use an ORDER BY clause in the main query, if you want the output sorted.
Output (using scott.emp):
ENAME           EMPNO        SAL         RN
CLARK            7782       2450          4
FORD             7902       3000          5
JAMES            7900        950          6This is the 2nd page; ADAMS, ALLEN and BLAKE would be on page 1.
I think the analytic ROW_NUMBER function is better than ROWNUM for this kind of thing.
Also, consider using variables instead of the "magic numbers" 2 and 3 in your WHERE clauses.
The following query produces the same results as the query above:
-- How many rows should appear on each page (except maybe the last page)?
VARIABLE  page_size     NUMBER
EXEC  :page_size := 3;
-- Which page do we want to display in this query?
VARIABLE  page_num     NUMBER
EXEC  :page_num  := 2;
WITH     got_rn     AS
     SELECT     ename, empno, sal
     ,     ROW_NUMBER () OVER (ORDER BY ename)     AS rn
     FROM     emp
--     WHERE     ename     LIKE 'M%'     -- Any filtering goes here
SELECT       *
FROM       got_rn
WHERE       CEIL (rn / :page_size)     = :page_num
ORDER BY  rn
;

Similar Messages

  • I am using firefox 3.6.7. with Windows 7. There is no " sort by name" in the dropo down when I right click. How do I alphabatize my book marks?

    I want to alphabetize my bookmarks. I am using Firefox 3.6.7 with Windows 7. When I right click on a bookmark no "sort by name" appears in the drop down. How can I do this/

    In Firefox 3 the option to sort bookmarks is only available for folders and not for individual bookmarks.
    Easiest to sort by name is to do that in the left pane of the Bookmarks Manager (Bookmarks > Organize Bookmarks) or in the sidebar and right-click the folder that you want to sort.
    See also http://kb.mozillazine.org/Sorting_and_rearranging_bookmarks_-_Firefox
    SortPlaces: https://addons.mozilla.org/firefox/addon/9275

  • ITunes 11: In the store, I can no longer sort by name/artist/album

    I can no longer sort by name or artist or album when I'm in the store with iTunes 11.  Yes, I discovered the View Options in the Menu Bar. By when I select it nothing opens. Same for Command-J. It doesn't do anything either. I've tried hitting Command-J repeatedly, but nothing.
    The fact is, it seems utterly stupid to have this work differently than when you're in your library---by simply hitting name/artist or album in the bar at the top of the list. Having to sort lists in the Store via a completely different method than the lists in one's library is totally counter-intuitive.
    But back to my problem:  The View Options won't open for me. Anybody know how to fix this?
    I've got a lot of music I wish to buy, but I need different methods of sorting, otherwise it'll be a nightmare trying to keep track of things.
    Thanks,
    Doug

    I have the same exact problem.  I am using a Windows computer running Windows 7.  I was able to see them prior to the installation of 10.4.  I have this problem on 2 computers and have a hard time believing that no one else is having this problem

  • RQ: Receive files in folder with name of the sende...

    Hello,
    I don't know is I'm on the right place and I don't know is there same request, so I apologize if it exist...
    Please, make option the received files to be saved in folder with the name of the sender. For example: my friend with skype name XYZ send me a file 'foo.bar' that will be saved in \My Documents\Skype_save (I changed the default dir); another friend with name XXY send me file 'foo1.bar' and again it will be in \My Documents\Skype_save, but when there are many files it is difficult to sort them and know whose files sended by who... So the good choise is if the files are saved in folder with name XYZ, XXY etc... Example:
    \Skype_save\XYZ\foo.bar
    \Skype_save\XXY\foo1.bar
    I'm sorry for my bad english, it's not my native language. I hope you can understand what I mean with this folders

    There is no automatic option in Skype that can do what you are trying to accomplish. However, you can in advance create save folders named as your contacts and and each time you receive a file, to save the file in the appropriate folder.
    For this to function, you have to set the option in Tools -> Options -> IM settings -> Show advanced options to “Choose a folder where to save the file every time”.

  • Elements 11 Sort By Name does not always sort by name

    If I choose Sort By: Name, MOST of the images are sorted properly by filename, but some are not.
    All my files are named YYYYMMDD####, but yet (for instance) in this view right now I have three files that start with 20150317 that are sorting BEFORE pictures with filenames 20150101...  Then everything goes sequentially as expected, right through the place in the sequence where these pictures SHOULD be.
    At the end of the sort I have similar problems.  If the sequence ends with (say) 20140414...., then there will also be pictures with filenames like 20150317 AFTER that.
    This makes no sense.  The system simply cannot be actually sorting by filename and having this result.  It's got to be using some metadata of some sort, not filename.
    I've looked at the advanced properties/metadata and there does not appear to be any difference between files that properly sort and those that show up out of sequence.
    What's the deal?

    Just to update this in case someone else is having a similar problem.
    First, I mis-spoke.  I'm on 12, not 11.
    With that, I do have all the right menu choices to "sort by name", however when I did that, it did not correct the sort order.  A very small fraction of what I had in the catalog (perhaps 1%) persisted in sorting by some unknown criteria.  Viewing the meta data or properties of the files did not show any differences between the files that were sorting "out of sequence" and those that were.
    At one point, thinking something had corrupted the catalog (I have a lot of files, who knows..) I "repaired" and then "optimized" the catalog.  No change.
    Ultimately what I did was (just to "try something") was delete the catalog entry for those files (not the files themselves) and then re-scan that folder.  Elements Organizer "found" the files again and imported them into the catalog.  After that, they now show up properly, sorted by filename, in the thumbnail view (by folder).
    So.. whatever it was, it was solved in this way.  We'll see if it now recurs.
    Thanks!

  • How do I alphabetize my bookmarks. "Sort by Name" option only sorts general bookmark folders, not actual bookmarks.

    I want to have my bookmarks displayed alphabetically but the "Sort by Name" option under "Organize" only applies to folders in the "Library". How do I just sort my list of bookmarks as I can easily do with IE?

    Look at SortPlaces: https://addons.mozilla.org/firefox/addon/9275

  • I can't get Sort By Name to work on the Bookmarks Menu. How do you sort your folders alphabetically?

    I have my bookmarks sorted in folders. When I create a new folder it goes to the end of the list. I have tried going into Bookmarks/Show All Bookmarks, right click on Bookmarks Menu and Sort By Name but nothing happens. I have to manually move the newly created folder.
    Pat

    ''Pat L [[#answer-679152|said]]''
    <blockquote>
    ''FredMcD [[#answer-679014|said]]''
    <blockquote>
    Open the Bookmarks Manager. Open the folder branch tree. On this tree,
    select the folder you want with a right click.
    </blockquote>
    I have no problem sorting an individual folder by name, I can't get the list of folders to sort. As you can see by the attached images, several folders I've added are at the bottom of the folder list and even after I right click on Bookmark Menu/Sort By Name, they don't alphabetize.
    Pat
    </blockquote>
    Sorry, here is the other image.

  • Sorting doesn't seem to sort by name - why?

    Having successfully migrated from Aperture to Photos I was surprised to find that the sorting function is minimal and doesn't appear to work.  With 'Keep sorted by date' unselected my pictures do not sort by name.  The only thing I seem to be able to sort by name is the Album in which I keep my folders of pictures within Photos.
    Can anyone advise?
    Thanks!

    When you changed the folder setting for iTunes, you may have noticed at the top of the dialogue box that is was changing the settings for that folder only. For instance, I did my little test on a drive named "Video". When I called up the View Options, the box specifically said Video at the top. So I knew the change was only going to affect that folder.
    There is a box at the bottom to Use as Defaults, but it still only affects that folder. I can't see a way to make the option global, which means you have to mark folders one at a time to calculate the subfolder sizes. Probably intentional as it can really slow down the Finder's response time when it has to sit there and tally up the contents of every folder you open, or reopen.

  • About 'Sort Artist' name

    Hi
    i am trying to find out,
    as some of my songs' "sort artist" is grey in color (instead of black),
    and if the "sort artist" content word is grey in color, it will automatically sort songs with same ARTIST name to have the same "sort artist" name.
    EG: if the ARTIST name is The Pussycat Dolls, and the "sort artist" name is Pussycat Dolls (grey in color instead of black), all songs ARTIST name with 'The Pussycat Dolls' will automatically change the "sort artist" name to Pussycat Dolls.
    EG: if the ARTIST name is The Pussycat Dolls, and the "sort artist" name is Pussycat Dolls (black in color), all songs ARTIST name with 'The Pussycat Dolls' will not automatically change the "sort artist" name to Pussycat Dolls.
    May I know how to set the "sort artist" name to become grey color so that it will automatically change the "sort artist" name for all ARTIST with the same name?
    Anyone's soonest help will be appreciated.
    Thank you
    Grace Tang

    Further to my question, when I plug in and select my iPad 2 I don't have the same problem.  I have restored the settings on my iPod Touch and updated both iTunes and iPod Touch software and restarted my iPod touch.  Nothing has made any difference.

  • My photo albums used to be sorted by name now they are sorted by date (ipod touch ) any ideas?

    my photo albums on my ipod touch
    were sorted by name now they are sorted by date taken .I didn't change any settings on my computer any ideas?

    You're in the Photo Mode with Event Titles displayed so you are looking at events.  But in this mode you can only sort the photos within the Events, not the Events.
    Go to the Events mode and there you can sort the events by: date, title or manually:
    FWIW albums arew those items in the left hand pane:
    OT

  • I surely would like to be able to 'sort by name' feature in my bookmarks like I do on the desktop version.

    In the desktop version of the firefox 'release' channel browser, you can simply choose a group of saved bookmarks, and then choose the 'sort by name' option to sort your bookmarks. I've installed the latest firefox mobile version on my lenovo ideatab A2109A tablet, and that feature doesn't exist. At this point in time there isn't even any addon available to use either. I surely enjoy using firefox on my windows computer's, and I DO realize that android is different from windows, but I would hope that someday in the near future..this 'important' feature can be added. In both the 'stock' android browser, boat browser, and also google chrome browser, this feature has already been implemented.
    Thanks,
    David

    Hi again David,<br/>I forgot to mention there is an option to provide feedback comments at http://input.mozilla.org/feedback
    It is a rational question.
    I do not know the answer but comparing the size and complexity of desktop versions of Firefox with Mobile I surmise it is one or all of:
    # hardware limitations: cpu & probably most importantly RAM.<br/> On a mobile RAM is used for the static files that would reside on a hdd plus any cache, in addition to what normally has to be in RAM.
    #development time & resources, this is a fairly new product
    #need for compatibility on lower spec devices
    You may also note there is a '''''Firefox OS''''' in development/rollout https://www.mozilla.org/firefox/partners/
    We try not to have off topic conversations on the forum because as an open and Search Engine indexed forum any discussion attracts further posts.

  • Sort by Name in style palettes (INDD CS3)

    Every time I add new styles to the Paragraph, Character, or Object styles palettes, I have to manually re-set the display to 'Sort by Name'. This was never necessary in CS2. Is there any way to set this as a default in CS3?

    It would be fine to have them be unsorted by default as long as there was a way to sticky toggle sorting on for those that prefer to work the old way. IMHO, the new folder system is something of an accident waiting to happen too if you don't set up for it from the very beginning.
    - Each folder is independent of every other folder or the top level, meaning you can have an "H1" head style in each folder and all of them be defined differently.
    - If you started with a flat hierarchy from CS2 imported into CS3, you can rapidly get your CS3 working documents into a hozed state if you aren't aware of the first point. If you organize your styles into folders, but then open an old CS2 document again and copy stuff across from it, CS3 will see that the old style(s) associated with whatever you copy don't exist at the top level (eg you copied them all into the Chapter Opener sub-folder) and it will then re-import the styles back into the top level again, which means that you now have your original CS3 stuff linked to a style in a subfolder and the stuff you just copied in linked to a similar style at the top level.
    Until you do some clean-up and figure out which style is supposed to replace over which, you can no longer rely on all your styled text being the same or on all your styled text changing when you change a style.
    - IIRC, there is no easy way to flatten the hierarchy, such that you can tell if you have duplicate names in various subfolders, which means that it's fairly incompatible with export to INX back to CS2. (I have a vague recollection of doing this experiment, but I could be wrong on this point.)

  • Sort by Name in nautilus Gnome 2.24

    Since Gnome 2.24 Nautilus is case sensitive in Sort by Name. First Upper case files and than lower case. (Desktop, Downloads, applications etc. it should have been applications, Desktop, Downloads etc.
    Can I change this somehow? Its really anoying since I got used in "normal" setup.
    Any ideas?

    foutrelis wrote:
    I recently had this issue as well. Turns out that LC_COLLATE is set to C in /etc/profile (line 41) and thus making the sorting case-sensitive.
    A solution I read on another topic (can't find it now) is to comment that line out (I've commented it from the export line as well):
    #LC_COLLATE="C"
    export HISTSIZE HISTCONTROL INPUTRC LESS #LC_COLLATE
    That makes sense.
    I just add export LC_COLLATE="zh_CN.UTF-8" to my ~/.profile, and everything goes fine.
    It might have sth to do with the latest gdm, since it used to sort by pinyin & case insensitive order.

  • UNDO SORT BY NAME IN TOOLBAR

    I SORTED BY NAME AND CAN NOT UNDO, JUST UPGRADED YESTERDAY, HAVE 5.0 FOR MAC OS X
    IT IS A MESS NOW
    I TRIED RESTORING TO DEFAULT-BUT THAT MADE IT WORSE, I DO NOT WANT FOLDER ICONS

    ''Remove folder and bookmark icons from Bookmark Toolbar, Sorting Bookmarks, and possibly undoing sort by name:''
    I can't think of a logical order within folders that works better than alphabetical in most cases -- one exception is a bookmarks folder containing bookmarks to create a set of app-tabs in a specific order controlled by prefixing by numbers or many bookmark separators. The bookmarks toolbar is a possible exception but I have all of my bookmarks automatically sorted. I make use of bookmark separators to group bookmarks so that bookmarks are sorted within each group but not moved to another group. Here is a picture of my Bookmark Toolbar
    :http://dmcritchie.mvps.org/icons/fx5_before_after.png
    Looks something like: [boldface are Folders (blue) vs. Bookmarks (red)]
    :'''*5.0* _ Blogs Chaos SUMO''' | # + < > G GV H L Pz Sp Wi |''' K S '''sw| nBk Sc '''BF BugsBML'''| ...
    :names are kept very short to save space on the toolbar 1-3 chars for most of them. The bookmarks there are used like toolbar buttons and they are all bookmarklets (contain JavaScript).
    The '''"K" folder''' on my bookmarks toolbar contains mostly [http://dmcritchie.mvps.org/firefox/kws.htm keyword shortcuts] most of which are bookmarklets, along with references to support and mozillazine articles. So I don't really need many bookmarks showing on the toolbar.
    The '''folder and bookmark favicons are removed by a style''' managed by the Stylish extension:
    * '''Stylish''' :: Add-ons for Firefox<br>https://addons.mozilla.org/firefox/addon/stylish/
    * '''Bookmarks Toolbar Fx4 Blue/Folders, Red/Bookmarks''' - Themes and Skins for Browser<br>http://userstyles.org/styles/46947/
    The '''Sorting of bookmarks is by an extension''', you can exclude any of the three major folders like the Bookmarks Toolbar. Don't use the automatic sort though, switch it to manual. Sorting takes about 3-5 seconds for all of my bookmarks.
    * '''SortPlaces''' :: Add-ons for Firefox<br>https://addons.mozilla.org/firefox/addon/sortplaces/
    Another place that I use '''bookmark separators''' is at the end of huge folders, so that I can review naming, content and keyword assigned before allowing into the main portion of a folder.
    You might be able to see your '''original bookmark order''' by going to the Library list ("Ctrl+Shift+B") and changing the order there on the "Views" menu > Sort > to "Unsorted". ("''Command''+Shift+B" on a Mac for the Library List)
    '''For additional help''' working with your '''bookmarks and history''' see
    * '''Bookmarks''' -- http://kb.mozillazine.org/Bookmarks
    * '''Sorting and rearranging bookmarks''' <br>http://kb.mozillazine.org/Sorting_and_rearranging_bookmarks_-_Firefox
    * '''Viewing the browsing history''' <br>http://kb.mozillazine.org/Viewing_the_browsing_history_-_Firefox

  • Sort by name apple mail

    My Mail is always sorted by date, but before, i could click on a mail, then click sort by name, to find another mail from the same person.
    Now when i click on sort by name, the first email dissappeers and i have to scroll threw my 10.000 mails to get to the letter from the persons name..
    As before it would stick with the mail i clicked on.

    [This is a C&P from Leopard days but the problem has started for me in Yosemite]
    Not sure if it is me or this is just the way Apple Mail works.
    Logic would assume that if you select a message in Apple Mail and that message is highlighted, not opened, and you click the From column so you can sort by that column Apple Mail would make sure that, when it is sorted, the highlighted message would still be in your view.  I can get this to work sometimes and other times it does not, so it is starting to bother me.
    Is there something that I am missing...some step...or is this just the way it works, sometimes?
    Thanks.

Maybe you are looking for

  • Can you use the same form for different datasheets?

    Hello! Thanks in advance for your time. To keep this short, I have created a form at my place of work to do a type of process audit. The form has worked extremely well and now other areas of the business would like to use it. For example, let's say I

  • External display suddenly isn't working any more

    Hello, I have a MBP 13 (mid 2010) running OSX 10.8.4 conected with a Dell 1707fpt via DVI cable. Everything worked fine without any problems until this morning and usually I have the MBP closed with an attached mouse and keyboard. Since this morning

  • Writing to a data file with time stamp - Help!

    My program currently asks the user to enter a path to save the data from my virtual channels. What I want is to have a default directory to store my data in and also have the file name that is created to be the date. I tried to use create open or rep

  • Automatic resolution detection and css loading

    Hi, Does anybody know if automatic detection of screen resolution is possible so that different css files may be loaded for different scree sizes. I'm trying to do this using javascript, but haven't had much luck. If you have any suggestions, do post

  • How do I install my Lightroom on a new system

    Last year I purchased Lightroom and installed it on my older laptop. I recently bought a new desktop system and a subscription to Adobe CC. I'm trying to find out how to transfer the install of Lightroom to my new system.