Rank numbers

I hope this isn't a stupid question, but I have a table of 12 lines. I have a column that class these lines from 1-12. Sometimes I want to change the position of two or more lines, who live the classification numbers because they follow the line that I'm moving. So, instead lines were appointed: 1, 2, 3, 4..., they find themselves as: 4, 1, 3, 2...  So I have to renumber the lines.

Is there a way to keep the numbering as 1, 2, 3, 4... etc no matter how I swap the positions of the individual line? I hope that makes sense.

Andy

for the column where you have the account numbers, 1 to 11

Use the rangee() function.  This function returns the line that they are in.

If you have a header, you must use

(rank-1)

Like this:

Select cell A2, and then type (or copy and paste it here) the formula:

= (−1) LINE

shorthand is:

A2 = (−1) LINE

Select cell A2, copy

Select cells A2 through A12, dough

Tags: iWork

Similar Questions

  • Update of the partition table and update rank with php.

    Hello

    I have a partition table on my site which is

    Scores: id - userid - ranking - points-

    Get points for doing things while using the site users. Points are updated, but I don't know how

    to update this user's position by comparing everyone elses points and rank numbers update

    based on the users with most points in php.

    Hope you can help. Thank you

    Weird, the link I provided is not what I wanted; It seems very different and is difficult to read. Anyway, you don't mention what goes wrong with the code you provided. I also don't think that you want to prepend rank alias with the table name 'notes' because it is not a table column. I do not use MySQL, but I think you want to use ' @' for your SQL local variables, so something like:

    $sqlgo = mysql_query ("SET @rank = 0; SELECT @rank: = @ row + 1 rank Users.id, Users.username, Users.profilepic, Scores.scoreid, Scores.userid, Scores.level, Scores.points, rank, Scores.badges OF Scores INNER JOIN users ON Scores.userid = Users.id ORDER BY invoking DESC LIMIT 30 ");

  • Numbers: trying to AutoFill for all dates the three weeks

    Numbers: You're Auto Fill dates for all three weeks?   Unable to do so... any suggestions... Thank you...

    Here's my proposal on what you ask for:

    Make sure that the table has 22 ranks as indicated.

    Enter the start date in cell E1

    A2 = 1 + INT ((ROW () −2) ÷7)

    It's shorthand dethrone select cell A2, and then type (or copy and paste it here) the formula:

    = 1 + INT ((ROW () −2) ÷7)

    B2 = MOD (ROW () −2, 7) + 1

    C2 = E1 + (−2) LINE

    Select cells A2 through C2, copy

    Select cells A2 at the end of the C column, paste

  • AppleScript for the development of Documents of numbers

    Hello!

    I just finished my first 'Real' Applescript to do something that I thought was pretty simple.

    It took me 5 days to figure it out!

    In any case, I regularly create new documents of numbers whenever I make a deposit in cash for the accountant of campus

    (I am a teacher/middle school band Director and am constantly receive payments from children for t-shirts, uniform band, travel expenses, etc.)

    I tried for years to find a way to compile all deposit slips in a single document to keep track of who paid for what during the school year and I always ended up having to manually copy and paste the data of each doc in the main list (last year I had more than one hundred different deposits slip files in a folder on my desktop).

    Long story short, I discovered Automator and Applescript a couple weeks ago and have been playing with them. Who would have thought that these tools had been all the time on my mac!

    If someone (much more qualified than me) could take a look at the code, I am come with below to see if she is healthy, of if there is a more effective way to achieve this, I very much appreciate it!

    The code works for now, but if there is something or any weakness that could break it in a future update, I would like to know about it.

    CODE BELOW:

    -------------------------------------------------

    -It is my attempt to create an AppleScript to copy data from several numbers documents and compiling a database for use in a single master Document numbers.

    -The way it's Setup now, whenever a new document data is added to the source folder, I double click on an icon on the desktop that runs this script.

    game of sourceFolder to (POSIX file ' / users/my_name/library/2016-2017 Financial Documents TO BE ADDED / " as alias)

    -source folder for documents to add to the main list


    game of to targetFolder (POSIX file ' / users/my_name/library/2016-2017 Documents financial/DONE / " as alias)

    -Place for documents to go after they are added to the main list.


    game dittos to (Choose file with prompt "choose a numbers Document to copy in the type list." as text by default location sourceFolder)

    -The script will ask me to select a file out of the source folder to copy


    say application "Numbers".

    activate

    the value doc to Open dittos

    say table 1 of the sheet active of the doc

    the value thisRangeName to '03:37.

    -the range I want to copy

    the value the range selection for range thisRangeName

    -selects the range I want to copy

    end say

    end say

    say application 'System events' to hit 'c' with the command down

    -copy the selected to the Clipboard.

    property docTarget: "/ users/my_name/library/2016-2017 band Documents/2016-2017 student List.numbers.

    -The location of the master file

    property today: current date

    -variable to use when entering information in the master file. This helps to sort the objects added to the master file.


    say application "Numbers".

    Open docTarget

    say 1 of table sheet "Sums of MONEY RECOVERABLE" of front document

    Add the line below last line

    -creates a new line to receive new information.

    the value the value of the last first cell at (today's date) string a line

    -between the current date in the first column of the table

    set the selection go in last second cell line

    -moves the selected cell to the one who will receive the data from the Clipboard.

    say application 'System events' to hit 'v' with the command down

    -Paste the Clipboard data

    say application "System events" of typing "ESC".

    -Deletes the currently selected cells

    end say

    -We will now check for empty lines that have been pasted from the source document to clean our Master Document.

    say 1 of table sheet "Sums of MONEY RECOVERABLE" of front document

    Set rowCount to (each line of the selection between)

    -the number of rows to check? Number of rows is determined by the amount of the previous selection range.

    Repeat with I of 3 for the count of number of lines

    -ignore the first 2 rows, which are header lines, the County

    the value may be to (value of fifth cell in last line)

    -checks the value of the fifth column (reason for the activity) to see if it is empty.

    If perhaps missing value then set went to last row

    -from the last line of the document, if the fifth column is blank, it is marked for deletion.

    Remove gone

    -remove the empty line

    end Repeat

    the value is in (value of fifth cell in last line)

    -When the repeated destruction are complete, if there is an extra empty line remains, it will get.

    If done then delete last rank missing value

    -the if statement that will remove the last extra line

    end say

    end say

    quit smoking application "Numbers".

    -close all documents of numbers and quit the application

    say application 'Finder '.

    move File to the folder targetFolder Dittos

    -move the Source file out of the folder "TO BE ADDED" and in the "DONE" folder.

    end say


    --------------------------------------------------


    Thanks for the help and advice of an Applescript Newbie!

    -Jimforxst

    First of all, if the script works for you, then it's good enough

    Even experienced/veteran AppleScripters can spend a lot of time to 'perfect' scripts, so it is important to balance the how long it will take to arrive at a solution that is "perfect".

    If you're looking for pointers that might work "better", here are a few thoughts.

    First of all, your script depends on literally copy and paste the data from the source file for the master file. I'm never a fan of this approach. All works (clearly), it is prone to error and changes the State of the system - not sure if what was in the Clipboard the script at startup has been sought, and the operator (if it wasn't you) do not doubt that the execution of the script would change the contents of the Clipboard. In general, I think it's better to reference the data directly ("set data2Copy to (get the ranks 1 to 37 of table 1...)"), although it works for now.

    In addition, your script is depends somewhat on the specifics of the source and master files. There is no error checking that the source data is valid before you copy it.

    On the same topic, you have a significant amount of code to check if the column 5 is empty. I would consider doing this check at the front - in other words only copies the data you need, rather than copy more and must clean up afterwards. Once again, the details of this function a bit on the data.

    Finally, for the moment, the script runs on a single file at a time - opens the source file, opens the master file, copies the data, close the files and closes way unexpected numbers.

    What happens if there are multiple source files to process? You can consider a loop through the files, the copied data and closing/smoke right at the end. That would save some time.

  • sum of only of positive numbers

    I'm the Dean in a high school and I need to keep track of demerits of the student and served detention.  I created a spreadsheet on the photo below.  As you can see whenever a student gets a demerit, I put it all in a row (date, teacher gives the incapacity, that was the incapacity and how many demerits received for the offence).  So you can imagine the end of the quarter, this worksheet is big enough (400-500 lines). I also put a negative number (-2) when the student uses of detention (a student must serve each received 2 drawbacks.

    I wrote about this formula on this forum almost two years ago.  I have another tab (sheet) that adds up all the disadvantages, so I can go to this (roadmap) tab and see who needs to serve.  The formula a = SUMIF (Sheet1! Header, header, Sheet1H:H) and it works beautifully. This other sheet has our entire student body on it (each student only listed time... If we have a student population of 300 students, it has only 300 lines). We add all the points (even negative), I can see that has more than 2 demerits and who needs to serve.  In the example below, Steve Abrahim would have 0 demerits on the second sheet because he received 4, but also served 4.

    But now, I realize that I need a second tab (sheet) that has the total number of demerits a student receives during the quarter.  Then, I need a formula that sums only positive numbers.  So, once again, this worksheet will have all our student body listed in the column (a student by rank).  On this tab (sheet), Steve Abrahim would be 4 demerits (even if he served two detentions) and Adam Butler would also have four (even if he served only a detention).  Can someone write this formula?

    Please let me know if you need any clarification on my question.

    Thank you

    Mark

    = SUMIF (E, ' > = 0 "" ")

    where I think the Points column is E

  • Separate the phone numbers on several lines

    Hello

    I have a list of phone numbers in a single column. Some cells have 1 phone number, some have 2, and some have 0. Cells with 2 phone numbers are separated by semicolons.

    I need all the phone numbers in a single column with 1 phone number in each row. The order does not matter, so I'll "Sort Ascending" once completed to get rid of the empty cells with no phone number.

    I need a function that takes the numbers after the comma and puts them on their own line in the same column.

    Note that the numbers are in the format: + 1-xxx-xxx-xxxx so if please be aware formatting as text and not as a mathematical equation.

    Thank you in advance.

    Hi B,

    Easy enough, as long as all entries are accurate according to the format you described. Here are two examples, all tous deux two on the same table. The selected cells are part of the first example and are not used in the second.

    End of flag: The two examples use the flag to end on the A11 to indicate when the formulas have reached the end of the list. As entered flag consists of eight occurrences of the text "end" (including the trailing space), with the final space deleted. This will be assimilated by the formula two phone numbers, provide an indicator of the end of each list.


    Example 1:

    Separates the first phone number in column B using this formula in B2, filled up to the last line containing a phone number in column A (or the line beyond if you want that the flag of the 'end').

    B2: = IF (LEN (A) < 1", LEFT(A,15))

    Len (A) checks no entry in its ranks. If that is found, IF put a string NULL. If there is an entry, LEFT out the first 15 characters.

    The second n phone number each line is copied into column C with this similar formula in C2 and filled up to the last line containing an entry in column A.

    C2: is equal to IF (LEN (A) < 16", RIGHT(A,15))

    If there are two numbers in this line from A cell, the semi colon will be the 16th character.

    After having extracted the numbers in two columns:

    Select all the cells in column B of B2 on the last containing a B10 number in this example). Copy.

    Go menu Edition > paste formula results

    Select all the cells in column C of C2 on the last containing a number C10). Copy.

    Click once on the empty cell in column B, following the list of the "first numbers" (B11 in this example).

    Go to edit > paste the results of the formulas.

    You can now sort the table according to the values (telephone numbers) in column B.

    Example 2:

    Separates the first phone number in column B using this formula in B2, filled up to the last line containing a phone number in column A (or the line beyond if you want that the flag of the 'end').

    B2: = IF (LEN (A) < 1", LEFT(A,15))

    Len (A) checks no entry in its ranks. If that is found, IF put a string NULL. If there is an entry, LEFT out the first 15 characters.

    The second phone number n that each line is copied into column B, starting after the cell containing the flag of the 'end '.

    Enter the following formula in the marketing of cells (B12 in the example) and fill down until the formula produces another flag to end.

    B12: = IF (LEN (A2) < 16", RIGHT(A2,15))

    Note that because this version of the formula is not on the same line as the EMF of the cell that is copied the phone number, it must the line included in the references.

    When the terminator is reached:

    Click on each of the cells that contain the end flags, and then press DELETE to remove the flags from the list.

    Select all THE cells B2 at the end of the list of telephone numbers. Copy.

    Go menu Edition > paste formula results

    With replaced by their latest results calculated formulas, you can now sort the table on column B.

    Kind regards

    Barry

  • Problem with the numbers in the rows of cut and paste

    Hey,.

    I'm new to MAC and now have problems with the help of figures, I brought my windows Excel worksheets. On windows, I could cut a line and paste anywhere on this page and by practice that Excel would fill the void rank where I cut the content. but here on MAC it does not work, why?

    anyway I tried to live with it by cutting a line and for the collage, I used Insert > copied lines for paste swath and add a line for her. but last night I updated the numbers and now by the practice precedes the Windrow is stuck this time with a resized form, the line is resized to a big line.

    Why is this happening? If it can't be fixed, I can go back to a previous version of a number? This update of hate.

    Numbers is excellent NO then you should consider to guide your expectations.

    Cut number refers only to the content NOT the line, or cells.  Select when a row, and then use the cut command that you cut the contents of the cells.

    If you try to move a line from one place to another, you should try this method (which can work for you)...

    Select the line, then click and hold on the header line (up to the line "lift" on the table), the operation slide the line to the destination.

    Now drag the line:

    Now drop the line where you want to:

  • Assign a separate value rank

    Hello

    I have the following table:

    CREATE TABLE 'BEFORE' ('LINE' VARCHAR2 (6), VARCHAR2 (2) "PATH", "PK" VARCHAR2 (3))

    /

    REM, INSERTING BEFORE

    TOGETHER TO DEFINE

    Insert BEFORE (LINE, WAY, PK) values ('570000', 'V1', '661');

    Insert BEFORE (LINE, WAY, PK) values ('570000', 'V1', '665');

    Insert BEFORE (LINE, WAY, PK) values ('570000', 'V1', '665');

    Insert BEFORE (LINE, WAY, PK) values ('570000', 'V1', '700');

    Insert BEFORE (LINE, WAY, PK) values ('570000', 'V1', '700');

    Insert BEFORE (LINE, WAY, PK) values ('570000', 'V1', '775');

    Insert BEFORE (LINE, WAY, PK) values ('570000', 'V1', '775');

    Insert BEFORE (LINE, WAY, PK) values ('680000', 'V2', '800');

    Insert BEFORE (LINE, WAY, PK) values ('680000', 'V2', '900');

    Insert BEFORE (LINE, WAY, PK) values ('680000', 'V2', '900');

    Insert BEFORE (LINE, WAY, PK) values ('680000', 'V2', '900');

    I would like to give a ranking in order to each distinct value in the KM of line and way field.

    Like this:

    CREATE TABLE 'AFTER' ('LINE' VARCHAR2(6 BYTE), VARCHAR2(2 BYTE) 'WAY', 'KM' VARCHAR2(3 BYTE), VARCHAR2(1 BYTE) 'RANK')

    /

    REM in AFTER INSERTION

    TOGETHER TO DEFINE

    Insert AFTER (LINE, WAY, KM, GRADE) values ('570000', 'V1', ' 661 ', ' 1');

    Insert AFTER (LINE, WAY, KM, GRADE) values ('570000', 'V1', ' 665 ', ' 2');

    Insert AFTER (LINE, WAY, KM, GRADE) values ('570000', 'V1', ' 665 ', ' 2');

    Insert AFTER (LINE, WAY, KM, GRADE) values ('570000', 'V1', ' 700 ', ' 3');

    Insert AFTER (LINE, WAY, KM, GRADE) values ('570000', 'V1', ' 700 ', ' 3');

    Insert AFTER (LINE, WAY, KM, GRADE) values ('570000', 'V1', ' 775 ', ' 4');

    Insert AFTER (LINE, WAY, KM, GRADE) values ('570000', 'V1', ' 775 ', ' 4');

    Insert AFTER (LINE, WAY, KM, GRADE) values ('570000', 'V2', ' 800 ', ' 1');

    Insert AFTER (LINE, WAY, KM, GRADE) values ('570000', 'V2', ' 900 ', ' 2');

    Insert AFTER (LINE, WAY, KM, GRADE) values ('570000', 'V2', ' 900 ', ' 2');

    Insert AFTER (LINE, WAY, KM, GRADE) values ('570000', 'V2', ' 900 ', ' 2');

    Thank you for your help

    Hello

    If you want to assign numbers (1, 2, 3,...) by order of pk without jumping all the numbers and duplicate the numbers when the pk value is duplicated.

    This sounds like a job for the DENSE_RANK function:

    CREATE TABLE after
    AS
    SELECT line
    way
    ,       pk                     AS km
    DENSE_RANK () (SCORE ONLINE
    ,             way
    ORDER BY pk
    ) AS rnk - GRADE is not a column name, good
    FRONT

    ;

    Thanks for posting the CREATE TABLE and INSERT statements; It's very useful!

  • Where are the numbers in the scope of the RGB Parade?

    I'm relatively new to the rank of speed but to understand the basics of color correction. I imported my media and shot upward with the analytical tools and none copes or waveforms have numbers on them to help me understand where the levels are in fact. There is barely any line in the graph either. I can't tell if I'm missing some sort of framework for SpeedGrade or if there is a problem with the program. Any thoughts?

    Well well, the word "laptop" explained all this. Your graphics card is very capable of handling things... especially for this screen. I've seen this before where the laptop screen is semi "stripped" of things & external is 'normal '. Be grateful, you can run... my laptop say Photoshop & Lightroom handles like a breeze. Fast & furious... but... video... nada. PrPro, just the box the long, slow & s l o w e r... SG? No case at all. The program rises and scopes to display like yours, but there is no picture in the playback window. Can I use the color wheels & watch the signals carried move... and that's all.

    Neil

  • Restart rank comes not correct based on column group

    Hello PL/SQL gurus and experts.


    I use Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64-bit Production version
    I have table-

    drop table t2;
    create table t2(Hospital,Test_Range,Total) as select
    'Batra','> 10 Mph','20000' from dual union all select
    'Fortis','1-3 Mph','24500' from dual union all select
    'Max','5-10 Mph','10600' from dual union all select
    'Columbia','< 1 Mph','27700' from dual union all select
    'Nimhans','< 1 Mph','50000' from dual union all select
    'Meenam','< 1 Mph','11000' from dual union all select
    'Meeran','5-10 Mph','24625' from dual union all select
    'Mnagamani','> 10 Mph','12000' from dual union all select
    'Murari','> 10 Mph','20600' from dual union all select
    'Triveni','5-10 Mph','16500' from dual union all select
    'Batra','5-10 Mph','14700' from dual union all select
    'Max','< 1 Mph','170000' from dual union all select
    'Apollo Medical Centre','> 10 Mph','19000' from dual union all select
    'MLal','1-3 Mph','22600' from dual union all select    
    'Columbia','< 1 Mph','28900' from dual union all select
    'Asian','1-3 Mph','27900' from dual union all select
    'A.G.M.','< 1 Mph','22700' from dual union all select
    'Aashiana','5-10 Mph','23450' from dual union all select
    'Amar Hospital','1-3 Mph','21325' from dual union all select
    'Childs Trust','5-10 Mph','22775' from dual union all select
    'Crescent ','< 1 Mph','20025' from dual;
    

    I use the following DML-

    select Test_Range "Test_Range",
    SUM (Total) "Total",
    decode(grouping(Hospital), 0, Hospital, 'Total') "Hospital",
    decode(grouping(Hospital), 0, max(rank), null) Rank
    from
    (
    SELECT Hospital,
             Test_Range,
             SUM (Total) Total,
             DENSE_RANK ()
                OVER (PARTITION BY test_range || Hospital ORDER BY SUM (Total) DESC)
                AS RANK,
             ROW_NUMBER ()
                OVER (PARTITION BY test_range || Hospital ORDER BY SUM (Total) DESC)
                AS rk
        FROM t2
    GROUP BY Hospital, Test_Range
    )
    group by grouping sets((Hospital, Test_Range),())
    order by Test_Range, Rank;
    

    Get the following output-

    Test_Ran      Total Hospital                    RANK
    -------- ---------- --------------------- ----------
    1-3 Mph       24500 Fortis                         1
    1-3 Mph       21325 Amar Hospital                  1
    1-3 Mph       22600 MLal                           1
    1-3 Mph       27900 Asian                          1
    5-10 Mph      14700 Batra                          1
    5-10 Mph      22775 Childs Trust                   1
    5-10 Mph      10600 Max                            1
    5-10 Mph      23450 Aashiana                       1
    5-10 Mph      16500 Triveni                        1
    5-10 Mph      24625 Meeran                         1
    < 1 Mph       20025 Crescent                       1
    Test_Ran      Total Hospital                    RANK
    -------- ---------- --------------------- ----------
    < 1 Mph       50000 Nimhans                        1
    < 1 Mph       56600 Columbia                       1
    < 1 Mph       11000 Meenam                         1
    < 1 Mph      170000 Max                            1
    < 1 Mph       22700 A.G.M.                         1
    > 10 Mph      12000 Mnagamani                      1
    > 10 Mph      20000 Batra                          1
    > 10 Mph      20600 Murari                         1
    > 10 Mph      19000 Apollo Medical Centre          1
                 610900 Total
    21 rows selected.
    

    While I am looking for following output-

    Test_Ran      Total Hospital                    RANK
    -------- ---------- --------------------- ----------
    1-3 Mph       27900 Asian                          1
    1-3 Mph       24500 Fortis                         2
    1-3 Mph       22600 MLal                           3
    1-3 Mph       21325 Amar Hospital                  4
    5-10 Mph      24625 Meeran                         1
    5-10 Mph      23450 Aashiana                       2
    5-10 Mph      22775 Childs Trust                   3
    5-10 Mph      16500 Triveni                        4
    5-10 Mph      14700 Batra                          5
    5-10 Mph      10600 Max                            6
    < 1 Mph      170000 Max                            1
    < 1 Mph       56600 Columbia                       2
    < 1 Mph       50000 Nimhans                        3
    Test_Ran      Total Hospital                    RANK
    -------- ---------- --------------------- ----------
    < 1 Mph       22700 A.G.M.                         4
    < 1 Mph       20025 Crescent                       5
    < 1 Mph       11000 Meenam                         6
    > 10 Mph      20600 Murari                         1
    > 10 Mph      20000 Batra                          2
    > 10 Mph      19000 Apollo Medical Centre          3
    > 10 Mph      12000 Mnagamani                      4
                 610900 Total
    21 rows selected.
    

    Kindly help me and thanks in advance for your time, effort and assistance

    Hello

    If you want a separate set of numbers (1, 2, 3,...) for each value of test_range, without seeking to hold account of the hospital, then the PARTITON OF only test_range, not to mention the hospital.

  • sequential numbers without using order by or partition of

    Hello
    My version of db: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production

    I write a query like this:
    SELECT location, value
    FROM params ep
        ,t2
    WHERE ep.model = 'M1'
        AND ep.etype = t2.etype   
    ORDER BY t2.orderid, ep.location
    
    output:
    location    value
    loc51    val51
    loc52    val52
    loc53    val53
    loc54    val54
    loc55    val55
    loc56    val56
    loc57    val57
    loc58    val58
    loc59    val59
    I want to change the sql, to get output like this
    location    value rank
    loc51    val51  1
    loc52    val52  2
    loc53    val53  3
    loc54    val54  4
    loc55    val55  5
    loc56    val56  6
    loc57    val57  7
    loc58    val58  8
    loc59    val59  9
    I see that if I used the analytical functions like row_number, rank etc, I must give an order by clause.
    But my requirement is, independently of any column, I want to be numbered sequentially.

    More like, get the exit first and then he number sequentially.

    Please advice.

    Published by: 934451 on June 4, 2013 10:45

    I just want to get the output of a sql and then he number sequentially.

    That's what rownum: http://www.orafaq.com/wiki/ROWNUM

    Do you mean that you use ORDER BY, but you have to number the lines after the order?

    SELECT location, value, ROWNUM
    FROM
    ( SELECT location, value
      FROM params ep
          ,t2
      WHERE ep.model = 'M1'
        AND ep.etype = t2.etype
      ORDER BY t2.orderid, ep.location )
    

    Published by: Rangel Marcus on June 4, 2013 15:02

  • Numbering on a repeating group

    I have the following:
    <?xml version="1.0" encoding="UTF-8"?>
    <DOCUMENT>
    <ROWSET>
       <ROW>
          <DOC_TYPE>Application</DOC_TYPE>
          <PROJECT_REF>A13003</PROJECT_REF>
          <TITLE>aasasdcvbb</TITLE>
       </ROW>
       <ROW>
          <DOC_TYPE>Application</DOC_TYPE>
          <PROJECT_REF>A13006</PROJECT_REF>
          <TITLE>dfgsdfg</TITLE>
       </ROW>
       <ROW>
          <DOC_TYPE>Final Report</DOC_TYPE>
          <PROJECT_REF>A13003</PROJECT_REF>
          <TITLE>aasasdcvbb</TITLE>
       </ROW>
       <ROW>
          <DOC_TYPE>Progress Report</DOC_TYPE>
          <PROJECT_REF>A13002</PROJECT_REF>
          <TITLE>testing application entry</TITLE>
       </ROW>
       <ROW>
          <DOC_TYPE>Progress Report</DOC_TYPE>
          <PROJECT_REF>A13003</PROJECT_REF>
          <TITLE>aasasdcvbb</TITLE>
       </ROW>
       <ROW>
          <DOC_TYPE>Progress Report</DOC_TYPE>
          <PROJECT_REF>A13005</PROJECT_REF>
          <TITLE>dfgdfgsdg</TITLE>
       </ROW>
    </ROWSET>
    </DOCUMENT>
    Then in my document, I want a unique table such that I have a line with the with the type of document, and then a line for each project_ref and title

    for example

    Agenda | Agenda | Page no..
    1. Welcome |
    2. Minutes of the last meeting.
    3. Request |
    3.1 | A13003 - aasasdcvbb |
    3.2 | A13006 - dfgsdfg |
    4. Final report |
    4.1 | A13003 - aasasdcvbb |
    etc.

    (1 and 2 are not the query)

    I ran the table Wizard with function group, for doc_type.

    <? for-each-group: ROW; / DOC_TYPE? > <? sorting: current-group () / DOC_TYPE; ' ascending '; data-type = "text"? >

    Then, I created 4 highest ranks with static data (welcome, minutes, blank lines). Move the the place holder for each group - in the cell before type of document, then the space reserved the end line in the last cell of the table.

    This seems to work well as each project is displayed in its own cell/row, however, for numbering I don't know which is better. I highlighted cells and specified for use word numbering. However, each different document type appears just as 3, with all the numbers behind appearing as the first level.

    Is there a good way to handle this? Or is it better to generate the numbering of the query?

    Is there a good way to add a blank line before each new type of doc?

    All advice appreciated :-)

    for the numbering, you can use position()

    not sure about the structure of the table, but as example

      .   
    
     3 Application
    3.1 A13003 aasasdcvbb
    3.2 A13006 dfgsdfg
     4 Final Report
    4.1 A13003 aasasdcvbb
     5 Progress Report
    5.1 A13002 testing application entry
    5.2 A13003 aasasdcvbb
    5.3 A13005 dfgdfgsdg 
    

    Published by: Alexandr on April 3, 2013 12:36 AM

  • extract numbers only by regexp_substr

    Hi all
    I want to get all the numbers, but do not include ' - '.
    example of
      with t as (select '12-12-2000'from dual union all
                select '12' from dual union all
          select '17.12' from dual union all
                  select 'February 2008' from dual union all
                  select '3 05 2010') as txt  from dual
    
                  )
        --
        select regexp_substr(txt,'[^- ][0-9.]*') from t;
    expected results
    only don't ranks No 2 and no ranks No 3
    12 
    12.17
    others do not need...

    concerning

    Published by: Isabelle January 11, 2013 01:26

    Try as...

    with t as
    (select '12-12-2000' val from dual union all
    select '12' from dual union all
    select '17.12' from dual union all
    select 'February 2008' from dual union all
    select '3 05 2010' from dual)
    select val from t where not regexp_like(val,'[-]|[ ]')
    
  • DENSE_RANK and find the top three rows return regardless of their rank.

    Oracle Database 10 g Express Edition Release 10.2.0.1.0 - product

    Hello

    I have the following problem;

    Dense_rank using I've categorized the trees in a plot of height.

    Now I need to filter the first three records by parcel based on the position of the trees, it's complicated by the fact that sometimes two or three of the three tallest trees have the same height.

    Records that I want to use for the parcel number 90001 are tree numbers 4, 5 and 3.

    Records that I want to use for the parcel number 31000 are tree numbers 4, 5, and 3, but rather the number 2 shaft is included.
    select distinct plot_number
         , tree_number
         , tree_height
         , dense_rank() over (partition by plot_number order by tree_height desc)ht_rank
      from tst_rank
      order by plot_number, ht_rank asc
    ;
    
    PLOT_NUMBER TREE_NUMBER TREE_HEIGHT HT_RANK
    ----------- ----------- ----------- -------
          31000           4          10       1 
          31000           5          10       1 
          31000           3           3       2 
          31000           2           2       3 
          31000           1           1       4 
          90001           5          20       1 
          90001           4          10       2 
          90001           3           3       3 
          90001           2           2       4 
          90001           1           1       5 
    
     10 rows selected 
    The dense rank function allows me to classify the trees, but then it has accomplished its purpose. The following query is an example of what I want to do - but - I need to access the 3 early accounts after the rankings were made, so the following query is not going to use the collation.
    select plot_number
         , max(decode(ht_rank, '1', tree_height*100)) ht_1
         , max(decode(ht_rank, '2', tree_height*100)) ht_2
         , max(decode(ht_rank, '3', tree_height*100)) ht_3
    from (select distinct plot_number
               , tree_number
               , tree_height
               , dense_rank() over (partition by plot_number order by tree_height desc)ht_rank
            from tst_rank
           order by plot_number, ht_rank asc
          )txt  
     group by plot_number
    ;
    
    PLOT_NUMBER HT_1 HT_2 HT_3
    ----------- ---- ---- ----
          31000   10    3    2 
          90001   20   10    3 
    But I want to see;
    PLOT_NUMBER HT_1 HT_2 HT_3
    ----------- ---- ---- ----
          31000   10   10    3 
          90001   20   10    3 
    Anyone have some ideas of what I could do to get there?

    See you soon
    Ben


    Create script to replicate my problem;
    -- drop table tst_rank;
    
    CREATE TABLE TST_RANK
    ( PLOT_NUMBER NUMBER
    , TREE_NUMBER NUMBER
    , TREE_HEIGHT NUMBER
    );
    
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('31000','1', '1');
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('31000','2', '2');
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('31000','3', '3');
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('31000','4', '10');
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('31000','5', '10');
    
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('90001','1', '1');
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('90001','2', '2');
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('90001','3', '3');
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('90001','4', '10');
    INSERT INTO TST_RANK (PLOT_NUMBER, TREE_NUMBER, TREE_HEIGHT) VALUES ('90001','5', '20');
    
    COMMIT;
    
    /*
    
    select distinct plot_number
         , tree_number
         , tree_height
         , dense_rank() over (partition by plot_number order by tree_height desc)ht_rank
      from tst_rank
      order by plot_number, ht_rank asc
    ;
    
    select plot_number
         , max(decode(ht_rank, '1', tree_height)) ht_1
         , max(decode(ht_rank, '2', tree_height)) ht_2
         , max(decode(ht_rank, '3', tree_height)) ht_3
    from (select distinct plot_number
               , tree_number
               , tree_height
               , dense_rank() over (partition by plot_number order by tree_height desc)ht_rank
            from tst_rank
           order by plot_number, ht_rank asc
          )txt  
     group by plot_number
    ;
    
    */
    Published by: benton on 9 October 2012 14:45

    Use ROW_NUMBER

    SQL> select plot_number,
      2         max(decode(rn,1,tree_height)) h1,
      3         max(decode(rn,2,tree_height)) h2,
      4         max(decode(rn,3,tree_height)) h3
      5  from(
      6  select plot_number,tree_height,
      7         row_number() over(partition by plot_number order by tree_height desc) rn
      8  from tst_rank)
      9  group by plot_number;
    
    PLOT_NUMBER         H1         H2         H3
    ----------- ---------- ---------- ----------
          31000         10         10          3
          90001         20         10          3
    
  • Place the missing documents in the list of records with a rank value

    Hi all

    I have this table:
    WITH taba AS (SELECT 99 AS id,
                         '2011-08-08' AS date_ini,
                         10 AS VALUE,
                         1 AS RANK
                    FROM DUAL
                  UNION ALL
                  SELECT 99 AS id,
                         '2011-09-08' AS date_ini,
                         11 AS VALUE,
                         2 AS RANK
                    FROM DUAL
                  UNION ALL
                  SELECT 99 AS id,
                         '2011-10-08' AS date_ini,
                         10 AS VALUE,
                         4 AS RANK
                    FROM DUAL
                  UNION ALL
                  SELECT 999 AS id,
                         '2011-08-08' AS date_ini,
                         10 AS VALUE,
                         1 AS RANK
                    FROM DUAL
                  UNION ALL
                  SELECT 999 AS id,
                         '2011-09-08' AS date_ini,
                         10 AS VALUE,
                         2 AS RANK
                    FROM DUAL
                  UNION ALL
                  SELECT 999 AS id,
                         '2011-10-08' AS date_ini,
                         10 AS VALUE,
                         3 AS RANK
                    FROM DUAL
                  UNION ALL
                  SELECT 9999 AS id,
                         '2011-08-08' AS date_ini,
                         10 AS VALUE,
                         2 AS RANK
                    FROM DUAL
                  UNION ALL
                  SELECT 9999 AS id,
                         '2011-09-08' AS date_ini,
                         15 AS VALUE,
                         3 AS RANK
                    FROM DUAL
                  UNION ALL
                  SELECT 9999 AS id,
                         '2011-10-08' AS date_ini,
                         10 AS VALUE,
                         4 AS RANK
                    FROM DUAL)
    SELECT *
      FROM taba
    And I need to return the same results but with the addition of records that have no rank. For new records the VALUE must always be zero (0) and the value of DATA_INI must have the same value as the order of the records immediately following. Just like that:
    99       2011-08-08     10     1
    99       2011-09-08     11     2
    *99       2011-10-08     0     3*
    99       2011-10-08     10     4
    999      2011-08-08     10     1
    999      2011-09-08     10     2
    999      2011-10-08     10     3
    *9999     2011-08-08     0     1*
    9999     2011-08-08     10     2
    9999     2011-09-08     15     3
    9999     2011-10-08     10     4
    I can do this using a loop procedure, but I want a filter query. ;)

    Thanks in advance.
    Filipe Almeida

    Hi, Felipe,.

    So, you want multiple copies of a few lines. In other words, if a value or rnk (RANK is not a column name right) is missing in a given id you want to with the next highest rnk and the same id line repeated 2 or maybe even several times. All copies will be identical, except that rnk will have the missing numbers, and the value will be 0 on all additional copies.

    A way to do that is to join your table (or something very similar to it, as in the example below) to a Meter of Table , which is a table (or a result set, in this example) counts 1, 2, 3,... up to however many copies may be required.

    WITH     got_rows_needed          AS
    (
         SELECT     id, date_ini, value, rnk
         ,     rnk - LAG (rnk, 1, 0) OVER ( PARTITION BY  id
                                                ORDER BY          rnk
                                )         AS rows_needed
         FROM    taba
    )
    ,     cntr               AS
    (
         SELECT     LEVEL - 1     AS n
         FROM     (
                   SELECT     MAX (rows_needed)     AS max_rows_needed
                   FROM     got_rows_needed
              )
         CONNECT BY     LEVEL <= max_rows_needed
    )
    SELECT    r.id
    ,       r.date_ini
    ,       CASE
              WHEN  c.n  = 0
              THEN  r.value
              ELSE  0
             END               AS value
    ,       r.rnk - c.n          AS rnk
    FROM       got_rows_needed  r
    JOIN       cntr             c     ON  c.n  < r.rows_needed
    ORDER BY  id
    ,            rnk
    ;
    

    By elsewhere, store date information in a VARCHAR2 column, such as date_ini, is a very bad idea. Use a DATE column.

    Published by: Frank Kulash, August 8, 2012 11:02

    RANK is a keyword from Oracle. (It is the name of a built-in function). If you specify your own columns of RANK, it will confuse people reading the code, and it can result in compiler errors, too.
    ID is also an Oracle keyword. To be sure, you can use another name, such as grp_id, instead of id.
    It is best not to name your own objects with any name of fArrondi in v$ reserrved_words.keyword.

Maybe you are looking for