Select the records in which the last character in the string is a letter

Hello
I have a STREET table with a field NAME where there is a single letter at the end of a few names that shouldn't be there. I want to select all names that are like that. For example: "GREENE * B *", "JOHN BATCH * J."

what I would do with this query, is to fill a field new name2 with the correct version of the name without the last letter. Ex: "GREENE B"-> "GREENE.
Would that be a RTRIM command?

Thank you!
update t
   set name= TRIM(SUBSTR(NAME,1,LENGTH(NAME)-2))
WHERE NAME LIKE '% %'
AND SUBSTR(REVERSE(NAME),2,1) = ' ' 

but, even once, REVERSE (TRIM (SUBSTR (REVERSE (NAME), 3))) would be much faster then using the length

Tags: Database

Similar Questions

  • Select the last character of a string

    Hello
    I want to select the last character of a string address. "For example, as a result of select ' 165 John Ave W '-'W '. I tried to use the RIGHT but it does not work. I am using sqlplus.

    SELECT RIGHT(ADDRESS,1) FROM addresses;
    ORA-00904: "RIGHT": invalid identifier

    I can't find that any select statement to get the result I want. Ideas?

    Thank you!

    You want: SUBSTR (, - 1).

  • Find the last character in a string aplhanumreic

    Hi guys first time poster long time hiding in the shadows, I hope someone can help me

    I put the stored username and I need to find the last character before the number, for example

    ABC123 that I would like to find c
    AB123 I would find b

    suggestions as to how I could do this?
    Thanks in advance

    Here's one way:












  • Select the string table drop-down list box.

    Hi all

    I want to select the combo box list based on a string in the entry, I don't know how to do this. I have a drop-down list box and the value comes from a database, what I want to do is I want to change the value of the selected box based on the existing value in the database drop-down list. for example, A, B, C D I strings in the drop-down list box, and then in my database, I have a field with the string C, I want to change the C to A. I can't enter the value of C in a string format, but I don't know how to be the first position of the drop-down list box in so the order of channels combo box will be C, A, B, d., the value of C

    Thank you

    Then just write a new array of strings, with the elements of the new agenda, to the "[] strings" - property.

    Either you must code something that allows you to create an array of strings with the elements in the order that you want them to be. If there is a reorganization only, you could do something like:

    -Get the array of strings [] from the drop-down list using a property node box.

    -Find the position of the element you want to place first and use "delete from table", which returns the new array and the element removed.

    -Build a new table 1 d of the deleted item and table remaining. Move to the second combobox Strings [] property of a node property.

  • any easier way to replace the last character in a string?

    That's what I got:
    select SUBSTR('tjgb005dy_01_31_08',1,LENGTH('tjgb005dy_01_31_08')-1)||'1' from dual;
    
    --
    tjgb005dy_01_31_01
    and I am enough fan of it. It's ugly and it's long.
    so, I wonder if you have better ideas?

    Thank you

    Even easier:

    select regexp_replace('tjgb005dy_01_31_08','.$','1') from dual;
    
  • Looking for the last element of a string defined in a specific character style

    I should find each space which is the last character of a string in a particular character style. For example, in the "123 456 789" passage (the underlined part here indicating a passage located in a specific character style), my ideal GREP search would produce a match after the number 6.

    How to do this?

    Define your character style in the Format Panel find, use this GREP: \s$

    $ is the match end-of-string location, and when you search for text in a style character style, the end of what this style is applied to is considered the end of the string.

    Peter

  • How can I prevent Pages 5.6.1 selecting the invisible when I change the text in bold, italic, etc. on a new line

    This is starting to annoy me a lot and I have not found something online that will solve this problem.

    Let's say I'm editing a file.

    Now I say "Oh, I need to put a"BOLD"two lines after the second 'Cogito ergo sum'"- so I go to this line and press Cmd + B (shortcut for "BOLD") and in this case:


    He selects the invisible! Now, let's say I write about it

    It disables the "BOLD"! What is the point of this? This makes me press the shortcut and then I have to press the arrow to the left. That you understand it's frustrating because it's a waste of 4 seconds, every time I want to change the style of the last line. And for someone who publishes an entire document, it is VERY frustrating.

    Can someone help me?
    I hope it's a clear description of the problem

    When you use the attribute text keyboard shortcuts, it's a good idea to show invisible, so that you know where click to place your insertion point - before selecting the keyboard shortcut. If you want to use these shortcuts, you must adapt to the way in which the Pages to do things and not try to make it work like MS Word.

    When you select the paragraph marks, the following keystrokes will remove them, right as well as your sense of humor.

  • By selecting the rope between some special characters

    Dear Senior
    Please guide me how to select the string from - channel selection - behind the edge-
    I mean I want to select the channel of the first indent of before the second indent
    example of
    1-OS MARKING-1072
    2 BONE POCKET TIE-1288
    3-OS ATTACH A-1073
    4-OS CUP-1128
    5-OS ATTACH B-1075
    POCKET 6 OS O/L-976
    7 REGULUS SLEEVE O/L-1221
    8-ARMHOLE F/L-804
    9-CARD MAKING-819
    10-BADGE TIE-820
    Result
    BONE MARKING
    OS LOCK TIE
    BONE JOIN
    CUTTING OF THE BONE
    BONE TIE B
    POCKET OS O/L
    REGULUS SLEEVE O/L
    ARM HOLE F/L
    BADGE MANUFACTURING
    BADGE TIE

    Hello

    Use INSTR and SUBSTR, like this:

    WITH     got_pos     AS
    (
         SELECT     str
         ,     INSTR (str, '-', 1, 1) + 1     AS start_pos
         ,     INSTR (str, '-', 1, 2)           AS end_pos
         FROM     table_x
    )
    SELECT     SUBSTR ( str
                , start_pos
                , end_pos - start_pos
                )       AS between_hyphens
    FROM    got_pos
    ;
    

    You can also use regulat expressions, but they will be slower.
    In Oracle 10.1 (and), for example:

    SELECT     REGEXP_REPLACE ( str
                     , '^[^-]*-([^-]*)-.*'
                     , '\1'
                     )     AS between_hyphens
    FROM    table_x
    ;
    

    From Oracle 11.1, you can also use REGEXP_SUBSTR.
    Again, it will be less effective than using SUBSTR and INSTR.

    I hope that answers your question.
    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
    Explain, using specific examples, how you get these results from these data.
    What do you do if the string does not contain 2 hyphens? If thiis is a problem, then include examples in your sample data and results.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).
    See the FAQ forum {message identifier: = 9360002}

  • Select from the table where the last character of the string is numeric

    Hello
    I have a table of STREETS with a field called ADDRESS. I want to select all the records in streets where the last character in the address is a number.
    Select ADDRESS of STREETS where regexp_like (substr (address,?,?,), '[0-9]');
    --? means that I don't know what to put here!

    I don't know if substr is the best approach to do this, because I want only the last character and the records are of different lengths.

    Thank you!

    Hello

    If you want to use regular expressions:

    WHERE     REGEXP_LIKE ( address
                  , '[0-9]$'
                  )
    

    You can get the same results, no doubt more effectively, without regular expressions:

    WHERE     INSTR ( '0123456789'
               , SUBSTR (address, -1)
               )     > 0
    
  • Select the last record of each month

    Hello

    to select the last docnumber and qty of every month

    Structure

    Name Null?    Type

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

    PRODUCTCODE NUMBER

    NUMBER NUMBER

    DATE OF PLANFORMONTH

    NUMBER OF CLEXPECTEDQTY

    NUMBER OF CLCONFIRMQTY

    NUMBER OF CLFGBUFFERQTY

    NUMBER OF CLTOTPRINTBUFFER

    in this select query if I take the sum he required all records where, as I want the last record of each month

    SELECT productcode docnumber MAX (Number), planformonth, SUM (clexpectedqty) clexpectedqty (planformonth) MAX.

    SUM (clconfirmqty) clconfirmqty, SUM (clfgbufferqty) clfgbufferqty, cltotprintbuffer OF FGSALESPLAN of the SUM (cltotprintbuffer)

    GROUP BY productcode, (planformonth)

    Sandy

    Hello

    Thanks its working now the code is written as below:

    SELECT * FROM

    (SELECT

    e.*,

    ROW_NUMBER() OVER (partition by PRODUCTCODE by DOCNUMBER DESC order) r

    Of

    E FGSALESPLAN)

    WHERE r = 1 AND

    entryvalid = 'Y '.

    order by Number

    Sandy

  • Select before the last character.

    I have some URLS in a picture like this

    http://test.com/ABC/ghgh.html

    http://test.com/BCD/

    http://test.com/FFF/default.aspx

    http:// test2.com/a

    I want to select all the items before the last.

    But if the last / is it after the .com can get just how it is.

    so before should translate into

    http://test.com/ABC

    http://test.com/BCD

    http://test.com/FFF

    http:// test2.com/a

    create table soqs2)

    URL varchar2 (50)

    );

    insert into soqs2 values ('http://test.com/abc/ghgh.html');

    insert into soqs2 values ('http://test.com/bcd/');

    insert into soqs2 values ('http://test.com/fff/default.aspx');

    insert into soqs2 values ('http:// test2.com/a "");

    SQL and PL/SQL are the same forum...

    Check my last response to your original thread select prior to last character /

  • How to select the last 3 records in a table?

    I have a table named HRM_ATTENDANCE
    as follows
    Name         Type         Nullable Default Comments 
    ------------ ------------ -------- ------- -------- 
    LEAVEDATE    DATE                                   
    EMPLOYEECODE VARCHAR2(8)                            
    LEAVETYPE    VARCHAR2(4)                            
    APPROVEDBY   VARCHAR2(8)  Y                         
    FEEDBY       VARCHAR2(8)  Y                         
    FEEDTIME     DATE         Y                         
    REMARKS      VARCHAR2(50) Y 
    the table contains the record of leave of employees as follows
    LEAVEDATE   EMPLOYEECODE LEAVETYPE APPROVEDBY FEEDBY   FEEDTIME    REMARKS
    ----------- ------------ --------- ---------- -------- ----------- --------------------------------------------------
    6/1/2013    00001        CL  
    6/3/2013    00001        EL                                         
    6/5/2013    00001        CPL    
    6/7/2013    00001        SL 
    6/9/2013    00001        CL                                        
    I want to select the last 3 leaves (records) to employeecode "00001" so I don't know the what are the dates of the leave. in easy words I want to choose the folder where leavedate > = 5 June 2013 ", but I don't know any dates."

    Select * from HRM_ATTENDANCE where rownum<=3 order="" by="" leavedate="">

  • Select the last 50 closed records

    The research of a statement select simple sql which selects the latest 50 records closed in the database.

    I found some help out there who have an example like:

    SELECT RecordID, closed_date
    (SELECT RecordID, closed_date, RANK() over (ORDER BY closed_Date DESC) date_rank
    FROM table1)
    WHERE the date_rank < = 50;

    Only problem is, this is to select something like 4000 recordings, and many of them are not yet closed.

    I think that you need to retrieve the records that are only closed in the first place.

    Try this,

    SELECT RecordID, closed_date
      FROM (SELECT RecordID,
                   closed_date,
                   ROW_NUMBER () OVER (ORDER BY closed_Date DESC) rn
              FROM table1
             WHERE closed_date < SYSDATE)  --Notice this.
     WHERE rn <= 50;
    

    G.

  • Select the last 10 records in a table

    Oracle9i. I am trying to select the last 10 numbers in a table with this command series
    select serial from tab_42 where employeecode='00001'  and rownum<=10 order by serial desc;
    but it's not not selecting the most recent serial number 10. How to do?

    The rownum clause is applied before the order by clause, one must use a subquery...

    select * from (select serial from tab_42 where employeecode='00001' order by serial desc) where rownum<=10;
    
  • If the record not found this particular date, then select the last recordings date.

    I have three columns
    Number DP_FND_CODE;
    Date of DP_DATE;
    Number DPPRICE;

    I want that if dp_uprice not found this particular date (: dd1) then
    Select maximum Dp_uprice that the date would be less then: dd1

    Example: -.
    I run query and :DD1 parameter = 18/10/2010
    
    SELECT dp_fnd_code, dp_date , dp_uprice dpprice 
    FROM dailyprice where dp_date = :dd1
    
    DP_FND_CODE DP_DATE                      DPPRICE
    ----------- ----------------------- ------------
              1 18/10/2010                  109.0344
              2 18/10/2010                   10.1045
              3 18/10/2010                  100.4010
              4 18/10/2010                  102.3276
              6 18/10/2010                   14.6958
              7 18/10/2010                   98.8300
              8 18/10/2010                  102.0900
    It will show that all the Archives: dd1 = 18/10/2010, you can see above the result of the query DP_FND 5 is missing.
    I want to if there is no DPRICE of that particular date (: DD1) then it shows the date of the last DPPRICE.
    Like this
    DP_FND_CODE DP_DATE                      DPPRICE
    ----------- ----------------------- ------------
              1 18/10/2010                  109.0344
              2 18/10/2010                   10.1045
              3 18/10/2010                  100.4010
              4 18/10/2010                  102.3276
              5 16/10/2010                  122.3276          
              6 18/10/2010                   14.6958
              7 18/10/2010                   98.8300
              8 18/10/2010                  102.0900
    so I used this query, but correct nicely.
    SELECT dp_fnd_code, dp_date, 
                 case when dp_uprice is null then(
               select max(dp_uprice) dpprice from dailyprice where dp_date < :dd1 group by dp_fnd_code,dp_date
               ) else dp_uprice  end dpprice 
      FROM dailyprice 
      where dp_date = :dd1
      order by dp_fnd_code
      
    Thanks in advance.
    SELECT dp_fnd_code,
           max(dp_date) keep (dense_rank last order by dp_date),
           max(dpprice) keep (dense_rank last order by dp_date)
      FROM dailyprice
      where dp_date <= :dd1
      group by dp_fnd_code
      order by dp_fnd_code;
    

Maybe you are looking for

  • I can not find the deleted messages in the trash can I have with outlook express

    I am unable to find the deleted messages in the trash can as I could when using internet explore how do I do in mozilla?

  • Why firefox is always as he installed the first time?

    Firefox always opens as program installed at the first time. I mean check the Add-ons and a screen of 'what's new' shows at the beginning, every time when I open it. Why is this happening? Windows 7 Home BasicLenovo Firefox 6.0.2Pentium P61003 GB ram

  • 4 - 1105dx

    I have a CRAVING for HP TouchSmart Ultrabook 4. Recently, my screen cracked and I'm trying to replace it. When I am looking for replacement screens say, LCD ONLY (WITHOUT touchscreen). It no longer does that mean if I get this one? Will it still work

  • Fastest sampling (software controlled)

    Hello I'm reading of data an accelerometer to Codemercs JoyWarrior 24F14. LabVIEW connection was easy as can be and reading to him as well. I want to use the sensor to measure the vibrations in one of our machines, so - as a test - I placed on the to

  • TV tuner initialization failed"when I start my computer

    Original title: TV tuner When I start, I get a message saying "failed to initialize of tunder TV."  Because of the digitization of television, I now have a TNT PCI but this message still appears.  Any suggestions please?