The last 4 values of lookup column

Is there a way to create a select statement that will do something like:


My_Number
1234561111
1234561112
2234561111
4234561111


SELECT * FROM TABLE WHERE my_number = (LAST 4) 1111

back 3 ranks.

I need to get the last 4 digits of this column. I don't want to make a SIMILAR, because there must be the LAST 4 and nothing in between.

Hi.Do you mean then?

C:\Documents and Settings\chinar>sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.2.0 - Production on Tue Jun 8 21:36:52 2010

Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> select n from (
  2  select 1234561111 as n from dual
  3  union
  4  select 1234561112 as n from dual
  5  union
  6  select 2234561111 as n from dual
  7  union
  8  select 4234561111 as n from dual)
  9  where substr(n,length(n)-3,length(n)) = '1111'
 10  /

         N
----------
1234561111
2234561111
4234561111

SQL>

Tags: Database

Similar Questions

  • How do the average of the last 5 values of a column as new values automatically entered?

    If the issue is not clear for you, here's a site I found that teaches you how do it on excel. ml https://www.extendoffice.com/documents/Excel/2533-Excel-average-last-5-values.HT    I can't find the corresponding method on the good numbers. Thank you for your response in advance :-)

    Hi Z_J,

    This number approach pulls the last 5 (low) values of table 1 in another table where the average can be calculated.

    Step 1. Add line numbers in column A of table 1. This gives a way for table 1-1 to extract the last 5 values.

    Formula in A2 (and fill down

    = ROW()

    Step 2.

    In table 1-1, the formula in A6 estimated the maximum line in table 1

    = MAX (Table 1::A)

    The formula in A5 (and filling up)

    = A6−1

    Formula in B2 of table 1-1 (and fill down) using VLOOKUP to find a match for each line number in table 1-1 and get the value out of this line in table 1.

    = VLOOKUP(A2,Table 1::A:B,2,FALSE)

    Step 3.

    Now add another row (and insert a new value) to the lower part of table 1

    Lines 3 to 7 are now drawn.

    Ranger by hiding some columns

    Kind regards

    Ian.

  • How show only last row value in a column of OBIEE

    Hi Experts

    How show only last row value in a column of OBIEE


    Thank you
    V

    Hello
    Pull column criteria, which you want to display only last row. Filter Advanced sql apply now to this column as a.
    RCOMPTE ("customer D1". "C1 Cust Name") = MAX (RCOMPTE ("customer D1". " Cust C1 Cust Name name')) here is the column where I applied the filter.
    So, it gives only last row in the name column of the Cust.

    Awarded points if the answer
    Reference: http://forums.oracle.com/forums/ann.jspa?annID=939

    Kind regards
    Srikanth
    http://bintelligencegroup.WordPress.com/

  • display the last 25 values in lov

    Hi How can I don't post that the last 25 values in my lov am in jdeveloper 11.1.1.6.0
    My iterator is
    <iterator Binds="CountryLOV1" RangeSize="-1"
                  DataControl="UAMAppModuleDataControl1" id="CountryLOV1Iterator"/>

    I guess you must write the request in a way that it returns the line that you want to see (the last n in your case).

    Timo

  • Help with the query to return the last possible value

    Can someone please help me to create a query for the situation below?

    Table: TABLEA
    Columns:
    FACID VARCHAR2 (10),
    DEPTID VARCHAR2 (10),
    CHARGENUMBER NUMBER (10)

    I have the following data:

    A, B, 1
    A, B, 2
    C, D, 3
    C, D, 4

    I will return the following:

    A, B, 2
    C, D, 4

    In other words, I would return the last possible CHARGENUMBER for FACID and DEPTID.
    The table has no index, and it is responsible for a worksheet in that order.

    Thank you very much!

    Hello

    If you have a TIMESTAMP column, called entry_dt, you can use a Top - N query like this to find the last x entries.

    WITH  got_rnum  AS
    (
         SELECT  my_table.*
         ,     RANK () OVER (ORDER BY entry_dt DESC)     AS rnum
         FROM     my_table
    )
    SELECT     *     -- or list all columns except rnum
    FROM     got_rnum
    WHERE     rnum     <= x
    ;
    

    It is very common to have a trigger to ensure that columns like entry_dt are met.

    If you have only one statement that inserts with hundreds of lines, they can all have the same entry_dt. (The value of SYSTIMESTAMP is constant throughout a statement, even if it takes a few seconds).
    The above query uses RANK, so if you tell him you want the last 10 entries, it can return more than 10, because it includes all lines with exactly the same entry_dt as the 10th. If you want to exactly 10 rows returned, even if there is a tie for 10th place, then use ROW_NUMBER instead of RANK; the rest of the query is the same.

  • Remember the last string value after you have closed the file exe

    Hello

    I have problem with storing data in the string.

    I work on small projects, where I need to print labels. I use to print the string control numbers. every time I close the full exe and re open the exe program, control of the chain not recalls last value entered and displayed in white. So, once again I have to memorize or take up the last value entered human and animal chain in it every time when I opened the exe.

    What should I do?

    Before closing your executable file, you must have the program write the value of this string of output to a file.

    When your program at startup, it should read the file and write the value in a local variable to this string.

  • Find the last valid value in a date range

    The data I work with represents readings from different instruments. A follow-up field of a sum running while this number continues to increase. I need to look at the data for a particular date, but the problem is that sometimes the instrument is turned off. In this case there is no data for that date, however since all I want is the total sum for the signal on this instrument, I need to keep going until I find the latest valid data in the database that would represent the sum up to this point. How can I design a query or procedure that would deal with this eventuality? Some examples of data:
    PV_ID                  SMPL_DTE                  INTEG_SINCE_VAL 
    ---------------------- ------------------------- --------------- 
    271                    20-JUL-08 12.05.00 AM     6172.0387459767 
    271                    20-JUL-08 12.06.00 AM     6172.0387459767 
    271                    21-JUL-08 12.05.00 AM     6172.0387459767 
    271                    21-JUL-08 12.06.00 AM     6172.0387459767 
    271                    21-JUL-08 08.43.00 AM     6172.0387459767 
    271                    21-JUL-08 08.45.00 AM     6172.0387459767 
    271                    22-JUL-08 12.05.00 AM     6172.0387459767 
    271                    12-AUG-08 04.45.00 PM     6172.0387459767 
    271                    12-AUG-08 04.50.00 PM     6172.038748687284 
    So, if for example I run a query for July 30, I would need to get the result of the July 22 because it is the last valid number. PV_ID represents the ID of the instrument and the INTEG_SINCE_VAL of the total cumulative for signal readings on this instrument.

    Published by: Solerous on March 16, 2009 07:23

    Published by: Solerous on March 16, 2009 07:25

    Hello

    If you want the last row or before a given date of the target as on July 30, 2008)?

    Here's a way

    SELECT  *
    FROM    (
            SELECT    *       -- or whatever columns you want
            FROM      table_x
            WHERE     sample_dte < TO_DATE (:target_dte, 'DD-MON-RR') + 1     -- See note below
            ORDER BY  sample_dte DESC
            )
    WHERE   ROWNUM = 1;
    

    NOTE: the above query adds a day to the current deadline, but selects the lines that are less important (not equal to) that link, so if you enter 30 July 08, it compares against 31 July 08, so he would choose anything on the date target itself, no matter what time. In other words, if you ask 30 July 08, you could get something later than 30 July 08 23:59:59, but you wouldn't get 31 July 08 12:00:00 AM.

  • Hi all, please help me to retrieve the last record value in field

    Hi all

    Shape the table below, I want to retrieve the latest data from column 4 disks in a new field that will be my field of view as shown in the end of the table by means of BI publisher, please help to achieve this goal.

    Column1 2 3 4 5 6

    May 1, 1067205671982868062
    May 1, 10034925706902868065
    15 May 102500005456901634220
    15 June 106000000-543101657501

    New field -54310

    Thank you and best regards,

    Prasad.

    something like

    for each: ByWhichLoop [last()]

    end foreach

  • query to get the maximum integer value of varchar columns

    I have the following values in the column of type Varchar.

    USR_LOGIN (VARCHAR2)
    -----------------------------
    50
    52
    53
    55
    57
    123
    111
    145
    XELSYSADM
    TESTUSER
    USER123
    12TESTUSER

    But I need to get the result as 145.

    Can you help me with the sql query?

    Maybe it's

    SQL> with t as (
     select '50' usr_login from dual union all
     select '52' from dual union all
     select '53' from dual union all
     select '55' from dual union all
     select '57' from dual union all
     select '123' from dual union all
     select '111' from dual union all
     select '145' from dual union all
     select 'XELSYSADM' from dual union all
     select 'TESTUSER' from dual union all
     select 'USER123' from dual union all
     select '12TESTUSER' from dual
    )
    --
    --
    select max(to_number(regexp_substr(usr_login, '\d+'))) usr_login from t
    /
          USR_LOGIN
    ---------------
                145
    1 row selected.
    
  • AS3/Fx3, if no 'save' between several lines added, all the lines contain the last modified value.

    Hi all

    I'm a sucker for creating problems. I'm working on adding role and content to a client website management. Currently, I have problems with the management of the role page.

    It is a legacy application and the customer is unwilling to upgrade to Coldfusion 8 and Flex Builder 3 Professional, so 'use the new stuff' is not enough for a response. No, I did not select the colors and I don't have the power to change their .

    It is a populous example:

    roleMgmt.png

    Here's the situation:

    1. The management of roles (mxml) page receives its data from a pair of files xml, siteManagement.xml, and roleManagement.xml through cffile calls via a cfc
    2. The xml data is stored locally in vars XML until the clerk.
    3. If I click once on the button 'Add', change the 'Save Changes' and fields immediately (the changes to the file through cfc is validated), everything works as expected, except that resets the combobox of roles. This normally isn't a problem - it is often exactly the behavior you want, but I can't stop reset.
    4. If I click on "Add control" more than once between save changes, changin any field on a new line causes all other lines have the same value for the same domain. (problem 2)
      1. This behavior can be fixed by saving and reloading the xml data between each click on 'add a control '. the problem with this solution is that it clears the Combobox of roles, adding unnecessary clicks to add (sometimes several) controls for the datagrid control.

    Controls are added by adding a new child element var XML:

    private function btnAddControl_click (): void

    {

    var tempXML:XML = new XML;

    tempXML = controlXMLTemplate;

    If (ensureFileExistsForRole ())

    {

    rolesXML.role [cbRolePicker.selectedIndex] .filename. (@fileName == cbChosenFile.selectedLabel).controls.appendChild (tempXML);

    }

    on the other

    {

    Alert.Show ("something does not work...", "Error Control adding :");)

    }

    dgcControlLabel.editable = true;

    dgcControlID.editable = true;

    dgcControlType.editable = true

    updateControls();

    supposed selects new line - this isn't

    dgControls.selectedIndex = rolesXML.role [cbRolePicker.selectedIndex] .filename. (@fileName == cbChosenFile.selectedLabel).controls.control.length ();        xmlDisplay.text = rolesXML;

    saveRoles();

    where controlXMLTemplate is:

    < control controlID = "Control ID' controlLabel ="Label control"controlType ="type"editable ="false"visible ="false"/ >

    and is added to the filename element:

    < canAccess filename = "true" fileName = "" friendlyName = "" > "

    < controls >

    < / controls >

    < / name of the file >

    I don't know what is causing the problem with the datagrid control where a line edit causes changes in others. My first thought was that it is caused by all the changes and selections via xml calls for example;

    dgControls.dataProvider = rolesXML.role [cbRolePicker.selectedIndex] .filename. (@fileName == cbChosenFile.selectedLabel).controls.control;

    So I added the code to add a number to the values that feed the datafields hoping that have unique data would cure the problem. There can be no.

    It's the function/code that causes the role Combobox to reset but prevents the datagrid problem:

    private function loadSiteInfo (): void

    {

    cursorManager.setBusyCursor ();

    roleManager.RO.loadSiteData.addEventListener (ResultEvent.RESULT, loadSiteData_resultsHandler);

    roleManager.RO.loadSiteData ();

    }

    private void loadRoles_resultsHandler(re:ResultEvent):void

    {

    cursorManager.removeBusyCursor ();

    roleManager.RO.loadRoles.removeEventListener (ResultEvent.RESULT, loadRoles_resultsHandler);

    rolesXML = re.result in XML format;

    }

    I don't know how much information you need to help. I can post the code if necessary, but I have to be careful - it's something health.

    This line is suspect:

    tempXML = controlXMLTemplate;

    This means that you may re-use of the same instance for multiple lines.  Probably, you need to copy the template rather than just use it.

  • Find paragraphs that begin on the last line of a page/column?

    It is possible to mark them?

    But here is not a solution the menu 'keep lines of the option '.

    (this is a request to the editor)

    The idea is to detect this kind of lines:

    Untitled1.jpg

    It should be pretty easy to score, for example with bar. But I don't see what the advantage in this operation would be compared to the use of the keep options.

    app.findGrepPreferences = null;

    app.findGrepPreferences.findWhat = "^."

    myFinds = app.activeDocument.findGrep ();

    for (i = 0; i< myfinds.length;="">

    myFind = myFinds [i];

    myLine = myFind.lines [0];

    If (myLine == myFind.parentTextFrames [0] .lines [-1]) myLine.strikeThru = true;

    }

    I think that should do it (even if it has completely not tested).

  • How to calculate the sum of the values of some columns in a table

    Hello

    I want to get the column just the average of the values of some columns not all columns of the table.what I have to change exactly in this block diagram.even if the table size is 25 average, I want the division as the number of values in each column (= number of lines)

    just like that:


  • How to return the highest value in a column of numbers less than a given number

    I am a beginner using formulas in number.  I have an inventory in a Numbers spreadsheet (v3.6.2).  Inventory numbers are in a column.  I need to view the last number used or the highest number less than a given value.  In my case, it is 9000.

    I can put a cell to return MAX and it's cool, but I need to know the number < 9000, MAX.

    Hi JS.

    SEARCH is your friend here. One of the properties of the LOOKUP function is that it accepts a 'close-match', which is defined as the largest value less than or equal to the search value.

    Formulas:

    A2: LOOKUP (8999.9999999, D)

    B2: LOOKUP(9000,D)

    C2: MAX (D)

    Kind regards

    Barry

  • Return a cell offset from the last value that is true

    I'm working on a document where I keep track of the amount of times my pieces band a certain song (this part, I figured out), but I also want to show what we played for the last time, we play a lot of songs the performance greater than 1. I have now a formula as shown below (sheet 1), but this does not automatically refresh when I insert a new playlist (on sheet 2), which is what I want. So, basically, I want to return the date that corresponds to the last time that a certain song is played, will be updated automatically during the extension of the list (on the sheet 2).

    I tried a lot of things, but I can't find a way to achieve this.

    Some relevant translations:

    -Sheet 1: 'Reply music' = last played

    -Sheet 2: "Optredens (bezetting)' = (irrelevant) performance--> all in one table, with cells unformatted (all white, without borders, sheet 2) to divide the performance and make it visually more attractive.

    I hope that someone of you can help me!

    Thanks in advance

    It looks like all your playlists are in a table in sheet 2. Ok.  It also seems that they are in ascending date order. It's also good.

    A way to do it is with the LOOKUP function. Search for the title of the song and have it return the corresponding date of the C column. Search the LOOKUP function in a column from the bottom to the top he will return to the most recent date, the lowest one in the table.  The direction she is looking doesn't seem to be documented officially, but I must have read somewhere, maybe in Excel.

    A simple formula looks a little like this (but with your name in the table 'table' No 2):

    = LOOKUP (C2, Table 2::B, Table 2::C)

    Note that the SEARCH will return a 'tight match' if the title of the song is not found in your playlist on any date. It can return a date to a different song. If you think that this can happen, wrap it in an if STATEMENT to check when the game in the D column number is 0.

    = IF (D2 = 0, ' ", list of CHOICES (C2, Table 2::B, table 2::C))))

    Note: Unlike the RESEARCH, VLOOKUP and MATCH of research from top to bottom.

  • How to find the value dated the same day in the last year

    I want to know how to find the value dated the same day in the last year.

    I use now, there is the function with the year and the result is

    Year Rev There are Rev
    20113000
    201240003000
    201320004000
    201450002000

    It works but it's not that I want. I'm trying to add the column date (Ex.20140101) in my report but it'snot work.

    I want to show:

    Date Rev There are Rev
    20110112200
    20120112100200
    20130112300100
    20140112500300

    If use (< degree >, < time_dim >. < date >, 365), it works but does not correct 100%

    Please help me...

    Thank you very much

    Check this link cool - bi.com

Maybe you are looking for