asscending Varchar2 column order, including the number of

Hello everyone.

I have a RANK_NO column. It contains values of integers from 1 to 12.
I want to organize the integers in the order of asscending with ORDER OF RANK_NO. It gives the following result.

1
10
11
12
2
3
4
5
6
7
8
9
Instead, I want them to be in order
1
2
3
4
...
12
There is no solution for this?
Best regards.

Ok

Maybe you want to do something like that?

with test_tab as
(select '1'  rank_no from dual
union all select '11' from dual
union all select '12' from dual
union all select '2' from dual
union all select '3' from dual
union all select 'A' from dual
union all select 'B' from dual
)  -- End of Test Data
select * from test_tab
     order by
        to_number (regexp_substr( rank_no, '[0-9]+')),
        regexp_substr( upper(rank_no), '[A-Z]+')
/

RA
--
1
2
3
11
12
A
B

7 rows selected.

SQL> 

Arun-

Tags: Oracle Development

Similar Questions

  • I just started using my new iMac 27 "and in Mail, I can't find the setting to display a column that shows the number of emails in each folder.  Mavericks, I had this column.  I have checked all the menus and preferences and search online.

    I just started using my new iMac 27 "and in Mail, I can't find the setting to display a column that shows the number of emails in each folder.  Mavericks, I had this column.  I have checked all the menus and preferences and search online.

    Click the triangle next to the Inbox to view the Inbox for each account. Then select the desired mailbox and the information will be displayed in the upper part.

    You are entitled to 90 days telephone support from Apple. Try to contact them.

    Apple Support contact

    Apple Support by email or chat

    Contact Apple Support - phone

  • ORA-01785: ORDER BY item must include the number of an expression in the SELECT list

    Apex 3.1.1 Oracle 10g

    Hello
    I get this error message sporadically and finally understood how to reproduce the error constantly. The problem occurs in a standard report using the SQL query (body of function from PL/SQL returning SQL query). I found several other posts stating the same problem like this: Re: report sorting limitation

    My example on apex.oracle.com is here: [http://apex.oracle.com/pls/otn/f?p=23292:4:427533145943010:] with credentials of comments/example. Run the page 4. If you click on demo_customers and sort on credit_limit, and then click demo_users, you should get the error. If you click Debug, you will see the following text:
    0.06: show report 
    0.07: determine column headings
    0.07: activate sort
    0.07: parse query as: WFU_CARS
    0.07: query could not be parsed:
    select  * from DEMO_USERS
     order by 11,1
    failed to parse SQL query:
    ORA-01785: ORDER BY item must be the number of a SELECT-list expression
    It seems that the ORDER BY clause is not set to zero? refreshing? When the source of the report is changed. Note that sorting on demo_customers on the column credit_limit column 11. When executing the query of demo_users, an ORDER OF 11.1 is added to the SQL statement.

    Any ideas how to solve this problem? Thank you!

    Lisa

    Lisa:

    You can reset the current so specifications whenever you build a new query for the report area. Thus, in the pl/sql that generates the report query, add this line of code just before returning the query string.

    apex_util. REMOVE_SORT_PREFERENCES;

    CITY

  • change the column size for the number

    Hello

    I created a table with a primary key declared under the (default specification) NUMBER column.

    Create table T

    (

    Number of key primary col1,.

    col2 varchar2 (10)

    );

    Then, I filled this table using the sequence. Now, I want to change the size of the primary key to the number (15) column.

    Is this possible without emptying the primary key column?

    You can't reduce the length of a column that has already given. But you can work around it like that.

    SQL> create table t  2  (  3  col1 number primary key,  4  col2 varchar2(10)  5  );
    Table created.
    SQL> insert into t  2  select level, 'a'  3    from dual  4  connect by level <= 10;
    10 rows created.
    SQL> desc t Name          Null?    Type -------------- -------- ------------------------------ COL1          NOT NULL NUMBER COL2                    VARCHAR2(10)
    SQL> select * from t;
          COL1 COL2---------- ----------        1 a        2 a        3 a        4 a        5 a        6 a        7 a        8 a        9 a        10 a
    10 rows selected.
    SQL> alter table t modify col1 number(15);alter table t modify col1 number(15)                    *ERROR at line 1:ORA-01440: column to be modified must be empty to decrease precision or scale
    
    SQL> alter table t add col_temp number(15);
    Table altered.
    SQL> update t set col_temp = col1;
    10 rows updated.
    SQL> commit;
    Commit complete.
    SQL> alter table t drop column col1;
    Table altered.
    SQL> alter table t rename column col_temp to col1;
    Table altered.
    SQL> alter table t add constraint t_pk primary key (col1);
    Table altered.
    SQL> desc t Name            Null?    Type --------------- -------- ------------------------------ COL2                    VARCHAR2(10) COL1            NOT NULL NUMBER(15)
    SQL> select * from t;
    COL2            COL1---------- ----------a                  1a                  2a                  3a                  4a                  5a                  6a                  7a                  8a                  9a                  10
    10 rows selected.
    SQL>
    
  • Script for counting both Yes and no in a column and returning the number of Yes on the Total

    (Acrobat Pro)

    I have 5 fields (DRDropdown1-5), who have 3 options (Y, N, NA). I only
    want to count the number of Y and N, then return the number of Y on the
    total of Y + N

    Any help is appreciated. I tell myself that if I see enough code, I'll get
    It is up.

    Thank you

    We are usually complete solutions, given a description or example of how to make the more difficult part, you should be able to take your knowledge of JavaScript and add the missing pieces. If you are not familiar with JavaScript, treat yourself and watch an introductory part (I like this for JavaScript in Acrobat: Beginning JavaScript for Adobe Acrobat ).

    Looking at your script, you already have most of the features in place. You should be able to edit the output (assuming that your domain may take a string and is not just a numeric field), by simply changing the last line:

    Change "event.value = total / total;" to the following:

    event.value = totalY + " of " + total;
    

    For easier reading, you can reformat the last two lines like this:

    if (total==0)
        event.value = "";
    else
        event.value = totalY + " of " + total;
    
  • development of the column according to the number of months in the quarter

    Hi all

    My need is to calculate the lines and write the result in the column:
    C1, if the current month is the 1st quarter,
    C2 if the current month is the 2nd quarter
    C3, if the current month is the 3rd quarter.

    How can I make it?

    Update: for example, today is August, this is the second month in the neighborhood, so I should write my value in C2.

    Published by: marco on 08/01/2011 07:43

    Marco wrote:
    BluShadow, Yes, this is one of the following ways.
    But what happens if I do not have the result column?

    You have not provided us with more information. My putting "train" there is for you to replace everything that you need need generate your result, to the extent that comes.
    Our crystal balls are broken right now, then, how you calculate your result belongs to you. the only thing you told us is that you calculate 'lines' for a 'result '.

    With regard to what you were actually asking however know how to differentiate which column to put the result in, this question has been answered.

  • Display a value in the column only if the number is greater than 1

    I need to return a value in the only if column the the count is greater than 1 for the same column.

    Example table:

    FOOD_TYPE Agenda COST_TO_BUY SELL_PRICE
    Ice creamChocolate0.502.00
    Ice creamVanilla0.502.00
    Ice creamStrawberry0.502.00
    ChickenWings2.005.00
    Bovine meatSteaks8.0015 h 00
    Bovine meatRoast10 h 006:00 pm

    In this example, I want to choose the POINT of FOOD_TYPE, SUM (COST_TO_BUY) AND SUM (SELL_PRICE), but I want only to select the ITEM if there is more than 1 points in the FOOD_TYPE.

    I tried all kinds of grouping and even including a case statement in select it as follows:

    CASE

    WHEN (COUNT (DISTINCT POINT) > 1)

    THEN THE POINT

    ELSE "

    END

    However, this is denied when I group because it forces me to use the POINT as a group and I can't use the set statement in the GROUP BY because it has an aggregate function.

    Help, please!

    with

    power as

    (select food_type 'Beef', 'Steaks' article, cost_to_buy 8.00 15.00 sell_price of all the double union)

    Select 'Beef', 'Roast', 10.00, 18.00 double Union all

    Select 'Chicken', 'Wings', 2.00, 5.00 double Union all

    Select 'Ice Cream', 'Chocolate', 0.50, 2.00 double Union all

    Select "Ice Cream", "Vanilla", 0.50, 2.00 double Union all

    Select "Ice Cream", "Strawberry", 0.50, 2.00 double

    )

    Select food_type 'Type of food. "

    cases where the head (separate) over (partition food_type) > 1 then end point "Item,"

    TO_CHAR (cost_to_buy, 'fm990.00') "Purchase cost"

    TO_CHAR (sell_price, 'fm990.00') 'selling price '.

    food

    food_type desc order

    Food Type Item Purchase cost Sell Price
    Ice cream Chocolate 0.50 2.00
    Ice cream Strawberry 0.50 2.00
    Ice cream Vanilla 0.50 2.00
    Chicken - 2.00 5.00
    Bovine meat Roast 10 h 00 6:00 pm
    Bovine meat Steaks 8.00 15 h 00

    Concerning

    Etbin

  • IS THE NAME OF THE PROFILE INCLUDES THE NUMBER TOO?

    PROFILE_NAME IS FOLLOWED BY A NUMBER. COPY THE NAME AND NUMBER TO RESTORE MY PROFILE? WHEN I DID IT BEFORE THERE WAS NO NUMBER BEHIND THE NAME.

    The name of the folder is what it is. If you rename, Firefox may lose track of it, so I would leave just the full name, exactly as it is.

  • Update of custom table and column based on the number of lines inserted in it.

    Hello

    I have a XX_TDP_DT custom table that has a column ID_processus.
    User will be be download data in the XX_TDP_DT table, but they insert any value into ID_processus.
    Say if the entered data are 1000 lines.
    I need to process these 1000 rows in batches, so I want to have 1 for 1 to 200 rownum = ID_processus, ID_processus = 2 for rownum 201 to 400 and so on.
    How can I achieve this, any suggestions?

    Database: 10g

    Thank you.

    You can also use NTILE to do this, see:
    Re: Divide also extracted almost lines and assign a group
    http://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:47910227585839

  • Reduce to basic appearance changes the path - video included the number

    Not sure why this barrier extends outside the track.  Does not seem to be a disconnect.

    To help to reduce base appearance in the appearance menu panel aligns the path and filling, but makes the largest path.  I want to keep it as is and use the path as it is currently displayed.

    This track comes from a file vector bought stock.

    Here's the video: http://www.screenr.com/Ozq7

    Thank you very much.

    Bradley,

    Is that what you meant?

    It has been.

    Now, this seems really strange and shouldn't be.

    Just to rule out the (im) possible: have you line up on the grid of pixels makes TIC TACS (only valid if the anchor Point to the left moves to a value in any point/pixel x)? There are two options to uncheck in the transformation Panel.

  • Column (varchar2) size does affect the performance of database?

    Hi friends,

    I have a table with most of the fields with the varchar2 data type and size of more than 1000. 99% of the scenarios I have no values greater than 100 size column, but as a precaution, I gave more than size. This affects the performance of the database or allocates more space in the tablespace? ...... Or it is fine if I have plus size column since it is a varchar2.

    Database: Oracle 11g

    Need your advice.



    Kind regards
    Suresh

    On disk, a VARCHAR2 column consumes only the number of bytes required to store the actual data. A string of 4 bytes in a column VARCHAR2 (1000) will consume only 4 bytes of space on the disk.

    Memory is a separate issue. In the structures of memory that deals with blocks (i.e. the cache buffers), blocks are identical to the blocks on the drive, so you would only store 4 bytes in the SGA for the VARCHAR2 field in the row discussed above. When you start writing PL/SQL code, however, Oracle can pre-allocate space for the VARCHAR2 variable. In PL/SQL, Oracle could pre-allocate 1000 bytes if you declare a VARCHAR2 variable (1000). However, Oracle would not pre-allocate memory if you declare a variable VARCHAR2 (3000) (here, the cutoff is 2000 bytes, see this askTom thread).

    Client network and the performance of allocation memory still is another problem. If you have a client application that is fetch data from the database, it has probably declare one large enough to hold the maximum size of each column in the result set, that it is fetching buffer. Related to this, the client application must be able to display the largest size of each field - if you allow a VARCHAR2 column (1000) but the GUI dies if you have over 100 bytes in the field, you have a problem.

    Finally and most importantly, is the model number of database. Columns should be sized to accept the amount of data required. It's a poor practice to declare tons of VARCHAR2 (1000) fields rather than appearing on the actual data size limits you want to apply and declare the columns for these fields sized correctly. Because it would be unwise to have a string of 500 bytes in a column of the CITY in a database, it wouldn't make sense to build a data model that would allow this situation.

    Justin

  • Count the number of rows returned from each view in USER_VIEWS

    For each USER_VIEWS view, I would return the name, creation date, last modified dateand the number of rows returned by this view.

    Here's what I have so far:
    col object_name format a20
    select 
    object_name, 
    created, 
    last_ddl_time
    from user_objects
    where object_type = 'VIEW'
    Returns:
    OBJECT_NAME          CREATED   LAST_DDL_TIME
    -------------------- --------- -------------
    AISLE_AVG            11-FEB-12 11-FEB-12     
    COURSE_AVG           11-FEB-12 20-FEB-12     
    EXE_12_VIEW          11-FEB-12 21-FEB-12     
    L1_P2                17-FEB-12 17-FEB-12     
    L1_P3                17-FEB-12 17-FEB-12     
    L1_P4                17-FEB-12 17-FEB-12     
    L1_P5A               17-FEB-12 17-FEB-12     
    L1_P5B               17-FEB-12 17-FEB-12     
    LAB3_1A              12-FEB-12 20-FEB-12     
    LAB3_1B              12-FEB-12 20-FEB-12     
    LAB3_2A              12-FEB-12 20-FEB-12     
    LAB3_2B              12-FEB-12 20-FEB-12     
    LAB5_1               19-FEB-12 19-FEB-12     
    LAB5_2               19-FEB-12 19-FEB-12     
    LAB5_3               19-FEB-12 19-FEB-12     
    LAB5_4               19-FEB-12 19-FEB-12     
    LAB5_5               19-FEB-12 19-FEB-12     
    LAB5_TIMES           19-FEB-12 19-FEB-12     
    LAB6_1               19-FEB-12 19-FEB-12     
    LAB7_VIEW            20-FEB-12 20-FEB-12     
    PROGRAMS             11-FEB-12 21-FEB-12     
    STUDENT_GPA          11-FEB-12 21-FEB-12     
    
     22 rows selected 
    How can I add a last column that counts the number of rows returned by this view?

    EDIT - here is a dump of my paintings, and here are my views.

    Edit2 - this is possible by using the DECODE function, by chance?

    The function...

    CREATE OR REPLACE FUNCTION view_row_count (view_name VARCHAR2)
    RETURN NUMBER
    AS
    retval NUMBER;
    BEGIN
    EXECUTE IMMEDIATE
    'select count(*) from '||view_name INTO retval;
    RETURN retval;
    END view_row_count;
    /
    

    And now the query...

    select
    object_name,
    created,
    last_ddl_time,
    view_row_count(object_name) as view_row_count
    from user_objects
    where object_type = 'VIEW'
    
  • generate the ramp of the order of the layers

    Is there a method (effect or script) that will apply a linear ramp to layers based on where they sit in the comp?  For example... If it is a composition of 100 layers, layer 1 would turn white and 100 layer would be black.  Any help or advice would be greatly appreciated... trying to figure out a quick solution to generate a picture of ramp based on the order of the layers.

    Thank you!

    Siri and my iPhone help me with this answer.

    You can apply the hue and saturation of your layer. You can then add an expression to the brightness value.  The expression is very simple.  It only requires that you know how many layers to use.

    If you have 100 layers and a composition of eight bits and then each layer must be reduced in luminance of 255÷100. Expressions include the number of layer by using the index of the expression.

    The expression looks like this:

    (index - 1) * 25.5;

    Now just duplicate your layer 100 times.

    The top will have a luminance you 04 Black, the background will have a luminance value of 255.

    I'll doublecheck this when I get to a computer, but I think it's perfect.

  • Impossible to make the link between the consistent readings with the number of physical block reads

    Hello

    The issue is that we have seen consistent readings are more than the total buffers necessary to give back the results.
    I emptied the buffer_cache before you execute the query and also questioned the V$ BH to know the details of the buffer for these objects... After the flush before you trigger the request that we do not have buffers about these tables. Which is expected.
    We are doing sequential reads of DB file with the plan and will result in a single block, read at a time.
    Please take a close look at "TABLE ACCESS BY INDEX ROWID CMPGN_DIM (cr = pr 45379 = 22949 pw = time 0 = 52434931 US)" line in the plan source line below...
    Here we have only 22949 data buffers 22949 means reading physical but we are witnessing gets 45379 coherent.

    Note: We have the CMPGN_DIM and AD_GRP tables in the tablespace size 4 M block and we have only the default db_cache_size. My database block size is 8192.

    Can you please help me understand how the 22949 sequential reads the result in 45379 coherent takes.

    Even the V$ BH query buffer details matches with physical reads.


    line source of 10043 trace query plan:

    SORT ORDER BY 27 (cr = 92355 pr 47396 pw = time = 0 = 359030364 en)
    27 WINDOW SORT (cr = 92355 pr 47396 pw = time = 0 = 359030088 en)
    NESTED LOOPS EXTRA-ATMOSPHERIQUE 27 (cr = 92355 pr 47396 pw = time = 0 = 359094569 en)
    NESTED LOOPS EXTRA-ATMOSPHERIQUE 27 (cr = 92276 pr 47395 pw = time = 0 = 359041825 en)
    VIEW 27 (cr = 92197 pr 47393 pw = time = 0 = 358984314 en)
    UNION-ALL 27 (cr = 92197 pr 47393 pw = time = 0 = 358984120 en)
    HASH GROUP BY 26 (cr = 92197 pr 47393 pw = time = 0 = 358983665 en)
    VIEW 9400 (cr = 92197 pr 47393 pw = time = 0 = 359094286 en)
    9400 COUNT (cr = 92197 pr 47393 pw = time = 0 = 359056676 en)
    VIEW 9400 (cr = 92197 pr 47393 pw = time = 0 = 359009672 en)
    9400 SORT ORDER BY (cr = 92197 pr 47393 pw = time = 0 = 358972063 en)
    9400 HASH JOIN EXTERNAL (cr = 92197 pr 47393 pw = time = 0 = 358954170 en)
    VIEW 9400 (cr = 92191 pr 47387 pw = time = 0 = 349796124 en)
    JOIN by HASH 9400 (cr = 92191 pr 47387 pw = time = 0 = 349758517 en)
    94 the TABLE ACCESS BY INDEX ROWID CMPGN_DIM (cr = pr 45379 = 22949 pw = time 0 = 52434931 US)
    50700 IDX_CMPGN_DIM_UK1 INDEX RANGE SCAN (cr = 351 pr = 349 pw = time 0 = 1915239 US)(object id 55617)
    TABLE ACCESS BY INDEX ROWID AD_GRP 60335 (cr = 46812 pr 24438 pw = time = 0 = 208234661 en)
    60335 INDEX RANGE SCAN IDX_AD_GRP2 (cr = 613 pr = 611 pw = time 0 = 13350221 US)(object id 10072801)
    VIEW 7 (cr = 6 pr = 6 pw = time 0 = 72933 en)
    7 HASH GROUP BY (cr = 6 pr = pw 6 = 0, time = 72898 US)
    162 PARTITION SINGLE PARTITION RANGE: 4 4 (cr = 6 pr = 6 pw = time 0 = 45363 en)
    162 PARTITION PARTITION UNIQUE HASH: 676 676 (cr = 6 pr = pw 6 = 0, time = 44690 US)
    162 INDEX RANGE SCAN PK_AD_GRP_DTL_FACT PARTITION: 3748 3748 (cr = 6 pr = pw 6 = 0, time = 44031 US) (object id 8347241)
    1 DOUBLE QUICK (cr = 0 pr = 0 pw = time 0 = US 9)
    25 TABLE ACCESS BY INDEX ROWID AD_GRP (cr = 79 pr = 2 pw = time 0 = 29817 US)

    user622572 wrote:
    Hi Charles,
    In this test of problem we have not any activity on my tables other than my session. If we do not have all cancel must be applied to the brand CR.

    * "So, which means the above?" *-->, that means the number of times where the blocks was visited is counted as CR not the number of buffers required to respond to a request. "

    * "" Why a plan of execution would change the number of makes more sense? "*--> changes in the method of access to the path and join required a different number of times the same buffer necessary visit." It means NL require more number of same buffer visits to T2, T1 and INT_T1_C2 as the hash join.

    * "' Why not flush the buffer cache would result in the PR drop statistics to 0, but does not change the statistics CR?" *--> each result buffer in physics RAS reads for objects from there which is why it cannot be zero in the first 4 tests where as test5 require PI (we don't rinse prior to that in your test case). " CR cannot be changed with buffer flush. Required CR same amount of pads and tampons visits regardless of buffer flush.

    It seems that we can say that "CR numbers include the number of times the block was visited in a query instead of just the number of buffers required". ""

    user622572,

    You deserve a lot of credit for having read and understood what I posted to correctly answer the questions I asked at the bottom of results and for your ability to answer your original question.

    Charles Hooper
    IT Manager/Oracle DBA
    K & M-making Machine, Inc.

  • The order of the enumeration returned by NISysCfgFindHardware()?

    Hello world

    Does anyone know if there is a particular to the devices list order returned by NISysCfgFindHardware()?  I use a PXI chassis with a bunch of cards, so I wonder if it is ordered by the number of accommodation or anything else, or maybe it's just random.  I don't have the material available right now, so I can't test it on mine thank you!

    I have attached a piece of code that I used to test this query.

    When I ran it I've always seen the controller at index 0 and the chassis at index 1. After that, generally the modules have been listed in the expected order, usually with 'white' in the indices corresponding to the empty slots. I saw interesting behavior after listing modules; for example, in a situation the chassis was registered again directly after the modules without empty spaces of the sale. My best advice would be to be safe and check each resource is what you expect before using it - but it doesn't seem to be a few inconsistencies that you could possibly take advantage of. Please feel free to use this code to test it yourself, but remember that this code has not been fully tested and cannot be guaranteed in all situations.

Maybe you are looking for

  • No access to bookmarks

    NONE of the statements in your files of information on access to the bookmarks will work for me... NONE of them and I've tried all. I want to go back to the previous version. How to do this. I appreciate your browser, but do not have the time to disa

  • Change ink cartridges

    My Officejet Pro 8500 tells me I need to change the ink cartridge, but it is not what color.  How will I know?

  • best chromebook?

    What is the best available in 2016 chromebook? Ive been watching chromebook review but I would like more input before making a decision. I got an old hp14 chromebook but the screen was not very good. I noticed the new 15-inch models an IPS display, b

  • can not scan as I used to

    put new hard drive in the computer and software hp reloaded... I have a pro 8600 printer. until I replaced my hard drive If I wanted to do anything all I had to do is click on hp8600 on the desktop and it would open a window and He asked you what you

  • Windows 7 does not take into account swap file settings

    I have Windows 7 Professional 64 bit installed on a system with a mirrored system disk and two disks no mirroring, including a SSD drive which is configured with ReadyBoost. Because mirroring is to the integrity of the data, and has a performance cos