Sorting In The Alpha Numeric Col In Oracle

Hi,
I have product table having product_name which can have values like 'STATEMENT Checking' and some 'statement savings' and some times like 123 and some times like '123 Certificate of Deposit'.
Here the requirement is all the numeric should come first and then the non numeric then also'STATEMENT Checking' and 'statement savings' should come one by one.We are using the upper case in the order by clause like ORDER BY UPPER(product_name) but the numeric fields are not coming properly like 100 seems to be less than 2 because it is sorting based upon the ascii value of the first character.
Is there any way to over come this.
Please suggest some ideas.
Regards,
Papi

Hi,
here is one way:
WITH mydata(txt) AS
  SELECT 'STATEMENT Checking' FROM DUAL UNION ALL
  SELECT 'statement savings' FROM DUAL UNION ALL
  SELECT '123' FROM DUAL UNION ALL
  SELECT '123 Certificate of Deposit' FROM DUAL UNION ALL
  SELECT '123 Test with same number' FROM DUAL UNION ALL
  SELECT '2' FROM DUAL UNION ALL
  SELECT '2 Certificate of Deposit' FROM DUAL
SELECT txt
   FROM mydata
  ORDER BY CASE WHEN REGEXP_LIKE(txt,'^\d+')
                THEN
                   TO_CHAR(TO_NUMBER(REGEXP_SUBSTR(txt,'^\d+')), '9999999') || REGEXP_REPLACE(txt,'^[\d]+')
                ELSE UPPER(txt)
           END;
TXT                      
2                        
2 Certificate of Deposit 
123                      
123 Certificate of Deposit
123 Test with same number
STATEMENT Checking       
statement savings         Please always remember to post some sample data (CREATE TABLE and INSERT STATEMENT or WITH clause like I did) and your expected output.
Regards.
Al

Similar Messages

  • Problem in the isNumeric rule in the Alpha Numeric Rule Library

    The rule isNumeric present in AlphaNumericLibrary is an out of box rule.
    I have found that this rule returns '0' for all types of inputs (numeric/alphanumeric/alphabetic).
    On further investigation I found that the "append" does not work and is just returning a null. I have pasted below a snapshot of the output of the append function.
    <append name='splitList'>
         <substr>
           <ref>testStr</ref> --> abc123def
           <ref>counter</ref> --> 8
           <i>1</i> --> 1
         </substr> --> f
       </append> --> null
    I have also pasted a snapshot of the final result I got while testing the rule.
    Configurator> rule "Alpha Numeric Rules:isNumeric" testStr 23456789 0
    Configurator> rule "Alpha Numeric Rules:isNumeric" testStr abcdefgh
    0
    Configurator> rule "Alpha Numeric Rules:isNumeric" testStr abc123def 0 Can anybody please help me in this case?

    The problem is in the StripNonAlphaNumeric Rule I believe. Instead of doing a <substr>, do a <get> of the current index on charList to produce the correct behavior.

  • Why don't my contacts sort onto the alpha pages of the Contacts app?

    New iPad. I'm entering contacts into the Contacts apps included. But they are all on one page with the alpha letter divider between the sections

    You backed the phone up to iCloud, but what were you syncing the contacts with? Apparently, it wasn't iCloud...

  • How to sort the alpha numeric character into number?

    Hi Good day!
    I have here a sample data as shown below that needs string manipulation to sort the metric sizes numerically.
    Select MetricSize From Sizes Order By MetricSize; which yields the following result:
    10 x 5.5 x 2
    125 x 95 x 13.5/21
    1264.01 x 1200 x 22.23
    130 x 105 x 12
    210 x 180 x 15
    28 x 16 x 15.2
    28 x 16.8 x 6/7.5
    52 x 25 x 10
    52 x 25 x 7/7.5
    52/58 x 25 x 7
    52/59 x 25 x 10/15.5
    55/61 x 35 x 11.5/16
    74.2/78.2 x 56 x 8/10.5
    74.5/79.5 x 45/42.5 x 12/13.7
    But the requirement is to sort this sizes numerically so that the output would be look like this:
    10 x 5.5 x 2
    28 x 16 x 15.2
    28 x 16.8 x 6/7.5
    52 x 25 x 7/7.5
    52/58 x 25 x 7
    52/59 x 25 x 10/15.5
    52 x 25 x 10
    55/61 x 35 x 11.5/16
    74.2/78.2 x 56 x 8/10.5
    74.5/79.5 x 45/42.5 x 12/13.7
    125 x 95 x 13.5/21
    130 x 105 x 12
    210 x 180 x 15
    1264.01 x 1200 x 22.23
    By the way the format for these sizes is composed of Outside Length x Inside Length x Thickness. But there are some sizes that contains slash '/' which is considered as special sizes.
    So one of my solution is to separate the numbers into 3 columns so that I can sort it by outside, inside length and thickness.
    Select MetricSize,
    Convert(Numeric(18, 2), Left(SubString(MetricSize, PatIndex('%[0-9.-]%', MetricSize), 100),PatIndex('%[^0-9.-]%',
    SubString(MetricSize, PatIndex('%[0-9.-]%', MetricSize), 100) + 'X')-1)) As Outside,
    Substring(MetricSize, charIndex('x', MetricSize) + 2, charIndex(reverse(Left(SubString(reverse(MetricSize),
    PatIndex('%[0-9.-]%', reverse(MetricSize)), 100),
    PatIndex('%[^0-9.-]%', SubString(reverse(MetricSize), PatIndex('%[0-9.-]%',
    reverse(MetricSize)), 100)))), MetricSize) - 4 - charIndex('x', MetricSize)) As Inside,
    Convert(Numeric(18, 2), Reverse(Left(SubString(reverse(MetricSize), PatIndex('%[0-9.-]%', reverse(MetricSize)), 100),PatIndex('%[^0-9.-]%',
    SubString(reverse(MetricSize), PatIndex('%[0-9.-]%', reverse(MetricSize)), 100) + 'X')-1))) As Thickness
    From Sizes Order By Outside , Inside, Thickness
    It is almost there but the result is not yet the exact result that I really wanted. There's a problem if the sizes contains slash '/' especially on the middle or the last portion of the character, which give me headache for a several minutes/hours. :)
    I need help for this problem. Your help will be greatly appreciated.
    Thanks in advance.
    Hardz

    create table #t (col varchar(100))
    insert into #t values ('10 x 5.5 x 2')
    insert into #t values ('125 x 95 x 13.5/21')
    insert into #t values ('1264.01 x 1200 x 22.23')
    insert into #t values ('130 x 105 x 12')
    insert into #t values ('130 x 95 x 12') --added
    insert into #t values ('210 x 180 x 15')
    insert into #t values ('28 x 16 x 15.2')
    insert into #t values ('28 x 16.8 x 6/7.5')
    insert into #t values ('52 x 25 x 10')
    insert into #t values ('52 x 25 x 7/7.5')
    insert into #t values ('52/58 x 25 x 7')
    insert into #t values ('52/59 x 25 x 10/15.5')
    insert into #t values ('55/61 x 35 x 11.5/16')
    insert into #t values ('74.2/78.2 x 56 x 8/10.5')
    insert into #t values ('74.5/79.5 x 45/42.5 x 12/13.')
    ;with mycte as (
    select col,
    parsename(Replace(replace(col,'.','*'),'X','.'),3) col1
    ,parsename(Replace(replace(col,'.','*'),'X','.'),2) col2
    ,parsename(Replace(replace(col,'.','*'),'X','.'),1) col3 from #t)
    ,mycte1 as (
    Select col,
    Cast(ISNULL(Replace(parsename(Replace(col1,'/','.'),2),'*','.'), Replace(parsename(Replace(col1,'/','.'),1),'*','.')) as Decimal(6,2)) col11
    , Cast(Replace(parsename(Replace(col1,'/','.'),1),'*','.') as Decimal(6,2)) as col12
    , Cast(ISNULL(Replace(parsename(Replace(col2,'/','.'),2),'*','.'), Replace(parsename(Replace(col2,'/','.'),1),'*','.')) as Decimal(6,2)) col21
    , Cast(Replace(parsename(Replace(col2,'/','.'),1),'*','.') as Decimal(6,2)) as col22
    , Cast(ISNULL(Replace(parsename(Replace(col3,'/','.'),2),'*','.'), Replace(parsename(Replace(col3,'/','.'),1),'*','.')) as Decimal(6,2)) col31
    , Cast(Replace(parsename(Replace(col3,'/','.'),1),'*','.') as Decimal(6,2)) as col32
    from mycte )
    Select col from mycte1
    Order by col11,col12,col21,col22,col31,col32
    drop table #t

  • Change the Alpha numeric project number sequence

    Hi guys
    Our project team is always copying Templates to new projects and for the year 2013, we need to set one of the template starting project number to 'SM130001' . We created this new value set with LOOKUPS, however have no clue how we can attach the same with template.
    We are on R 12.0.6, RHEL 64Bit
    regards,
    raj
    Edited by: rthampi on Feb 13, 2013 4:01 AM (spelling)

    Okay guys, I found it. This was done through a personalization. Sorry for the trouble.
    regards,
    raj

  • TS3276 I need feedback for the following issue. When I send email from this 27 inch iMac, the computer adds a string of characters in vertical column that represents the QWERTY key board, all alpha numeric characters are included. Yahoo mail, issue only o

    Restating my issue / question...
    When I send email from this iMac, there is a string of characters assigned. The characters are all the "alpha numeric" characters on the QWERTY key board. This only occurs when email is sent from this iMac. The issue does not manifest when using any other lap top or computer.
    Hence, I have ruled out the issue is a yahoo mail matter.
    Again, I can access the Yahoo mail account form multiple devices and send email without unintended assignment of character strings, but when I send wmail using this iMac, the issue happens everytime.
    Characters are stacked verticaly in a column. It looks as if all characters (except function keys) are included in the string.
    Any ideas?
    GMc

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It won’t solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    Third-party system modifications are a common cause of usability problems. By a “system modification,” I mean software that affects the operation of other software — potentially for the worse. The following procedure will help identify which such modifications you've installed. Don’t be alarmed by the complexity of these instructions — they’re easy to carry out and won’t change anything on your Mac. 
    These steps are to be taken while booted in “normal” mode, not in safe mode. If you’re now running in safe mode, reboot as usual before continuing. 
    Below are instructions to enter some UNIX shell commands. The commands are harmless, but they must be entered exactly as given in order to work. If you have doubts about the safety of the procedure suggested here, search this site for other discussions in which it’s been followed without any report of ill effects. 
    Some of the commands will line-wrap or scroll in your browser, but each one is really just a single line, all of which must be selected. You can accomplish this easily by triple-clicking anywhere in the line. The whole line will highlight, and you can then copy it. The headings “Step 1” and so on are not part of the commands. 
    Note: If you have more than one user account, Step 2 must be taken as an administrator. Ordinarily that would be the user created automatically when you booted the system for the first time. The other steps should be taken as the user who has the problem, if different. Most personal Macs have only one user, and in that case this paragraph doesn’t apply. 
    Launch the Terminal application in any of the following ways: 
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.) 
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens. 
    ☞ Open LaunchPad. Click Utilities, then Terminal in the icon grid. 
    When you launch Terminal, a text window will open with a line already in it, ending either in a dollar sign (“$”) or a percent sign (“%”). If you get the percent sign, enter “sh” and press return. You should then get a new line ending in a dollar sign. 
    Step 1 
    Triple-click the line of text below to select it:
    kextstat -kl | awk '!/com\.apple/{printf "%s %s\n", $6, $7}' | open -f -a TextEdit 
    Copy the selected text to the Clipboard by pressing the key combination command-C. Then click anywhere in the Terminal window and paste (command-V). A TextEdit window will open with the output of the command. Post the contents of that window, if any — the text, please, not a screenshot. You can then close the TextEdit window. The title of the window doesn't matter, and you don't need to post that. No typing is involved in this step.
    Step 2 
    Repeat with this line:
    { sudo launchctl list | sed 1d | awk '!/0x|com\.(apple|openssh|vix)|org\.(amav|apac|cups|isc|ntp|postf|x)/{print $3}'; sudo defaults read com.apple.loginwindow LoginHook; } | open -f -a TextEdit 
    This time you'll be prompted for your login password, which you do have to type. Nothing will be displayed when you type it. Type it carefully and then press return. You may get a one-time warning to be careful. Heed that warning, but don't post it. If you see a message that your username "is not in the sudoers file," then you're not logged in as an administrator. 
    Note: If you don’t have a login password, you’ll need to set one before taking this step. If that’s not possible, skip to the next step. 
    Step 3
    launchctl list | sed 1d | awk '!/0x|com\.apple|org\.(x|openbsd)/{print $3}' | open -f -a TextEdit 
    Step 4
    ls -1A /e*/mach* {,/}L*/{Ad,Compon,Ex,Fram,In,Keyb,La,Mail/Bu,P*P,Priv,Qu,Scripti,Servi,Spo,Sta}* L*/Fonts 2> /dev/null | open -f -a TextEdit  
    Important: If you formerly synchronized with a MobileMe account, your me.com email address may appear in the output of the above command. If so, anonymize it before posting. 
    Step 5
    osascript -e 'tell application "System Events" to get name of every login item' | open -f -a TextEdit 
    Remember, steps 1-5 are all copy-and-paste — no typing, except your password. Also remember to post the output. 
    You can then quit Terminal.

  • Unable to replicate both Numeric and alpha numeric vendors records from R3

    Dear all,
    In our ECC 5 environment, we have some vendors who master record numbers that are numeric internally assigned i.e 7000000 or 23000000 and some alphanumeric externally assigned i.e SmallBusiness1 or Grinad10. This is posible as you may know via vendor account groups.
    We have implemented a classic scenario in SRM 4, Server 5 environment, therefore we need to replicate ECC backend vendors masters. We initally set SAP's AB business Partner (vendors) number range in SRM to A  - zzzzzzzz and created numeric number ranges to match thoes set up for all our vendors in ECC.
    When we ran BBPGETVD only the alpha numeric vendors records replicated down to SRM. The numeric were ingnored. The BBPGETVD t-code was reporting that the other vendors had incorrect data.
    We then chnaged the AB Business Partner (vendor)number range to 000000001 - 999999999 and ran BBPGETVD. Only then did the numeric vendors get replicated down to SRM. But the issue is now, I cannot replicate the alpha numeric with out chaanging the number range back to A - zzzzzzzzz.
    Question,
    How can I set the Business Partner(Vendor) number range in SRM to anable the replication of both Numeric and Alpha numeric assigned vendor records down to SRM.
    Thanks,
    Grace

    Christophe,
    PLEASE HELP I HAVE AN URGENT ISSUE NOW!!!
    On the subject of setting back the internal BP number range, does SRM expect it to be set for example to:
    01  0000000001 - 0000999999?
    Should the grouping for this internal number range be also ways set to 0001. Iam refernceing the settings in our sandbox client, they seam to be set up that way.
    If its set to say 0003, will this cause a problem?
    Because we have set all our BP ranges to external, any ORG unit, USER or position that we created after we "removed" the internal number range does appear to be working.
    I have noticed this. when I login as a new user and try to create a shopping cart, tthe product category drop down does not work on the "new user".
    If I go in the BP transaction and search for this new user or new unit org units that where created after the removal of the internal number range nothing is found!. The last internal BP number is 105.
    Question.
    If I set the internal number range back to
    01 0000000001 - 0000099999 and set the current number to 106, then delete and recreate the org units, do you think this will work?
    Please help I need to get this issue sorted out because as you said no new org unit/user can be setup.
    Thanks Again.
    Grace

  • Removing alpha numeric characters

    Hi,
    Can anybody please tell me how can I remove the alpha numeric characters, inluding spaces from a column value.
    Thanks in advance

    Thanks for the help. But this extracts the alpha
    numeric characters and and print those. What I need
    is i want all those column values without these alpha
    numeric characters.You said...
    Can anybody please tell me
    how can I remove the alpha numeric characters, inluding spaces from a column value.So I showed you to to remove alpha numeric characters and spaces from a column value.
    So I think you need to be clear in your requirements.
    Do you want all rows where there are values that only have alpha numerics in them i.e. don't show the rows that have non-alpha numeric or spaces in a particular value?
    or
    Do you want all rows, but you want to strip out non alpha-numerics and spaces from particular values?
    Perhaps if you give an example of your data and what you expect the result to be that may give us a better idea, because what I gave you as a solution was correct for the requirement you specified.

  • Entering numbers on the alpha/nume​ric keypad

    How do i enter numbers on the alpha/numeric keypad of my HP 6500?  trying to put in network password.
    Thanks

    Hi,
    Simply use the keypad as you type an SMS (atleast used to type on the old generation cell phones )
    Simply click the number key several times till the required number appears on the screen.
    Shlomi
    Say thanks by clicking the Kudos thumb up in the post.
    If my post resolve your problem please mark it as an Accepted Solution

  • The entries in "Notes" are shown sorted by date of creation. Can they be sorted alpha/numerically?

    I would like to be able to sort the entries in "Notes" alpha numerically. By default these entries are sorted based on the date of creation of the entry.

    As I said, it works perfectly well for me. Try putting the sidebar into Contact Sheet mode and see if the dates are sorted correctly. Here's an example from my machine:
    As you can see, if you have good eyes, all are arranged in date order, regardless of day, month or year.
    Just two things occur to me about your problem. I see that your date format differs significantly from mine. Try changing it in System Preferences->Language & Text->Formats and see if that has an effect. There may be a bug in regard to how Preview handles the various date formats. You might also try logging into your test account and see if Preview behaves correctly there, with everything in the default state. If you don't have a test account, create one. Leave everything in the default state and keep it around for future tests--it doesn't take much space and is very handy to have around.
    Francine
    Francine
    Schwieder

  • Trouble sorting in alpha-numeric order

    Can someone please help me figure out why iPhoto doesn't know how to sort things alpha-numerically by title?
    For example, I am importing photos from my hard drive. Numbers go 1-200 as they should. However when I get into iphoto (set to sort by title), iphoto decides to go 1, 10, 100, 2, 20, 200, 3, 30, etc. Its very annoying since they are no longer in the right order. 1 should be next to 2, not 10. Computers have been ordering things in number order for ages, why is iPhoto so confused?
    Are there different settings that will import things properly. I know if I was using albums, I could make sure the album is set to sort "manually" prior to importing. Then they will be in their original order. I can't do that when just importing into iphoto/events as far as I know.
    Any suggestions?

    iPhoto sorts jsut fine - soem human had mis-names the photos
    "space" "space" 1 does not sort Alpha-Numerically to the same place a 001 - nor does 1 sort the same as 001
    An Alpha Numeric sort considers both Alphabetic and Numeric characters and therefore if you want the sort to match your expectiations then you need to be sure the characters you are sorting on are correct - the conmputer can not read yoru mind and see that you do not really want an alpha-numeric sort after all
    LN

  • Sorting of alpha numeric characters in a column`

    Hi All,
    I have a column which has alpha numeric characters like 1A, 12B, 14D, 12CC ...etc.
    I need to sort this column in ascending as well as descending. The normal "sort by" does not work and the ASCII function return on the ascii value of the 1st character in the cell.
    Can you please help me out?

    Needed more sample data..
    For provided data, ie if Number comes only at the beginning, you can ..
    SQL> select c1
      2  from t
      3  order by to_number(translate(c1,translate(c1,'a0123456789','a'),' ')),c1;
    C1
    1A
    12B
    12CC
    14D                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How do I copy/paste full numerical-only account strings into the Projects WebADI template when the account segment fields in the template require use of the dropdown because they're formatted as alpha-numeric values?

    How do I copy/paste full numerical-only account strings into the Projects WebADI template when the account segment fields in the template require use of the dropdown because they're formatted as alpha-numeric values? I'm using the Integrator named "Projects - Transaction Import" and a custom Layout created based on the seeded Layout named "Transaction Import - Accounted". Do I need to somehow change my Layout to make the Document accept numerical values instead of requiring alpha-numeric values? I need to be able to populate the Document with a large amount of transactions and cannot feasibly go through every transaction to add the alpha-valued name of the account segment to every segment that requires it. The segments in particular causing the problem are "Expnd Type" and "Organization Name" which are both alpha-numeric and as such contain the segment number and name; I need to be able to only have to enter the Natural Account Number (6-digit number only) and the Organization Number (5-digit number only).

    How do I copy/paste full numerical-only account strings into the Projects WebADI template when the account segment fields in the template require use of the dropdown because they're formatted as alpha-numeric values? I'm using the Integrator named "Projects - Transaction Import" and a custom Layout created based on the seeded Layout named "Transaction Import - Accounted". Do I need to somehow change my Layout to make the Document accept numerical values instead of requiring alpha-numeric values? I need to be able to populate the Document with a large amount of transactions and cannot feasibly go through every transaction to add the alpha-valued name of the account segment to every segment that requires it. The segments in particular causing the problem are "Expnd Type" and "Organization Name" which are both alpha-numeric and as such contain the segment number and name; I need to be able to only have to enter the Natural Account Number (6-digit number only) and the Organization Number (5-digit number only).

  • How to make the Internal numbering as Alpha-Numeric

    Hi,
    In the Document Info Record, the Internal numbering is always numeric.
    How to make it Alpha-Numeric?
    Regards,
    Shashi

    Dear Shashidhar,
    Number assignment is derived from Document Type of the DIR. You can customise the Document type settings (DC10) to make the number range as External or Mixed.
    Modify the settings in "Number Assgmt" tab as 2 for only external number assignement and 3 for mixed number assignment.
    Hope this solves your question.
    Regards,
    Sudharshan

  • Instructions for entering serial number for Elements 13 are to enter 24 alpha/numeric figures.  The SN on the Elements 13 box are 18 numeric only?

    The instructions for downloading Elements 13 are to enter a 24 alpha/numeric serial number.  The serial number on the box is 18 numeric digits.  How can I download without the required number of digits?

    Find your serial number quickly

Maybe you are looking for

  • Too many real instruments; Need help bouncing tracks

    Hello, I've been using GarageBand to record a demo for my band. Unfortunately, I've hit my peak number of real instrument tracks. I have a lot of tracks that are the same (well, not EXACTLY the same, but the same musical part), where one is panned le

  • Can't connect to wireless printer D110 Photosmart

    I've tried several times now to connect to this printer wirelessly - I'm in college and it is my roommate's printer, and she apparently didn't got through the whole process of inserting the cd and going through installation and so on, but is effectiv

  • Netflix Would Not Play on Mac OS X (Lion) After Upgrade

    Netflix would not play on Mac OS X v10.7.5 After I upgraded to my older mac to Mac OS X Lion it would not play.  MacBook 13-inch, Aluminum, Late 2008 Software  Mac OS X Lion 10.7.5 (11G63) Processor 2.4 Ghz Intel Core 2 Duo Memory 4 GB 1067 MHz DDR3

  • How can I sync my devices with a new computer?

    I have just purchased a Macbook Pro and I want to back up my devices and sync them with the new computer. How can I change the set up of my iphone to sync with my new computer instead of the old Dell desktop that I had?

  • Trying to get TOPN to work.  Doesn't seem to work with percentages.

    Resolution History 23-JUL-09 10:21:01 GMT In a data model in an xdo file I have the following statement: SELECT Dictator.Surname||', '||Dictator.Forename "Dictator Name", SUM(CASE WHEN "- Raw Data".STAT = 'U' THEN 1 ELSE 0 END)"STAT Jobs", "- Job Tot