Select from table where last character in string is numeric

Hello,
I have a table STREETS with a field called ADDRESS. I would like to select all records from streets where the last character in Address is a number.
Select ADDRESS from STREETS where regexp_like(substr(address, ?,?,), '[0-9]');
--? means that I don't know what to put in here!
I'm not sure if substr is the best approach for this, since i only want the last character and the records are of varying lengths.
Thanks!

Hi,
If you want to use regular expressions:
WHERE     REGEXP_LIKE ( address
              , '[0-9]$'
              )You can get the same results, probably more efficiently, without regular expressions:
WHERE     INSTR ( '0123456789'
           , SUBSTR (address, -1)
           )     > 0

Similar Messages

  • How do I do SELECT * FROM TABLE WHERE KEY IN ({list})?

    The title says it all really.
    Is there a reasonable performant way to perform the query
    SELECT * FROM TABLE WHERE KEY IN ({list})where {list} is String []?
    I am currently creating a PreparedStatement with a for loop like this   StringBuffer sb = new StringBuffer ("SELECT * FROM TABLE WHERE ID IN (");
      for (int ii=0;ii<keys.length;ii++) {
        sb.append (keys [ii]);
        if (ii != keys.length-1) sb.append (",");
      sb.append (")");but this means that the prepared statement is created each time I call my method and so I'm not sure that the optimizer will find it easy to cope with. Is there a construction that I'm missing along the lines of SELECT * FROM TABLE WHERE KEY = ? where I can create the PreparedStatement once and just call setObject or something on it when the values in {list} change?

    but this means that the prepared statement is created
    each time I call my method and so I'm not sure that
    the optimizer will find it easy to cope with.You are right, the optimizer won't find that easy to deal with (presuming that is even relevant for your driver/database.) But most optimizers won't do anything with statements that change and that is what you are doing.
    You could create several prepared statements which have a common number of bind variables. For example 10 statements with from 1 to 10 bind values. This will work if most of the queries use those.

  • Can I simulate SELECT * FROM TABLE WHERE ROW IN (1111,2222) using SQLJ

    I have a fct like
    public void fct(String inStr) {
    String str = "SELECT * FROM TABLE WHERE ROW IN" + inStr;
    // then I xecute the query using JDBC connection
    But I want to do the same thisn using SQLJ like:
    public void fct(String inStr) {
    #sql [nctx] iter = { SELECT * FROM TABLE WHERE ROW IN :inStr}
    When I run the second version and give a parameter like "(1111,2222)" it gives
    ORA-01722: invalid number error.
    Is there a way to give parameters to in clauses of SQLJ statements.
    Thanks in regard.

    This is a SQLJ FAQ. You can find the FAQ at:
    http://technet.oracle.com/tech/java/sqlj_jdbc/htdocs/faq.html
    Your question is addressed in the following section:
    http://technet.oracle.com/tech/java/sqlj_jdbc/htdocs/faq.html#variablesizevaluelist
    Note that that section has a typo. The lines:
    ? // populate mynumbers
    #sql { SELECT * FROM tab WHERE col in (:(a[0]),:(a[1]),?};
    should read:
    ... // populate mynumbers
    #sql { SELECT * FROM tab WHERE col in (:(a[0]),:(a[1]),...};
    By the way, with the next release SQLJ will support pasting in of dynamic SQL fragments. Then you'll be able to do pretty much what you are trying to accomplish here (albeit with slightly different syntax). Until then you'd have to use the workarounds from the FAQ.

  • How to achieve that "SELECT * FROM table WHERE age BETWEEN 18 AND 23 AND n"

    How to achieve the SQL like that "SELECT * FROM table WHERE age BETWEEN 18 AND 23 AND name = 'Will' " with BDB C-API
    The primary key in the primary database is 'age' ,and the secondary key in the secondary index is 'name' ,in a lot of examples ,there are all simple , but how to do that complex one.thx~

    but this means that the prepared statement is created
    each time I call my method and so I'm not sure that
    the optimizer will find it easy to cope with.You are right, the optimizer won't find that easy to deal with (presuming that is even relevant for your driver/database.) But most optimizers won't do anything with statements that change and that is what you are doing.
    You could create several prepared statements which have a common number of bind variables. For example 10 statements with from 1 to 10 bind values. This will work if most of the queries use those.

  • Reason behind this query ,SELECT * FROM table WHERE 1 0

    HEllo,
    I would like to know the reason behind using this query ,
    SELECT * FROM <table> WHERE 1 < 0
    before executing the actual SQL query.
    Is there any special reason or the JDBC receiver side is configured like that.
    Is there any option to overcome this process like, can we remove this option or stop using this.
    Why the JDBC adapter basically sending this query on the DB?
    Thanks,
    Soorya,

    Hi,
    if you run this query, you wont be able to see any records of the table.
    SELECT * FROM <table> WHERE 1 < 0
    if you run this query you will see all records
    SELECT * FROM <table> WHERE 0 < 1
    same with SELECT * FROM <table> WHERE 1=1
    So you can check this out that whats happening in your code before executing actual query. just try to co-relate.
    regards
    Aashish Sinha
    PS : reward points if helpful

  • Select * from table where rownum 5; no rows returned? why is it so?

    select from table where rownum > 5;*
    no rows returned. why is it so?
    can anyone explain me?

    Hi,
    rownum is pseudo column, and it is based on the sort order.
    For ex, if you want to get the first 5 employees who get the least salary, you use,
    select ename,sal from
        (select ename, sal
         from emp
         order by sal )
        where rownum<=5
    ENAME      SAL                   
    SMITH      800                   
    ALLEN1     890                   
    JAMES      951                   
    TURNER     998                   
    ADAMS      1100Suppose, if you want to use highest salary, you change the order by and not the rownum. So, it becomes,
    select ename,sal from
        (select ename, sal
         from emp
         order by sal desc)
        where rownum<=5
    ENAME      SAL                   
    KING1      5000                  
    FORD       3000                  
    SCOTT      3000                  
    JONES      2975                  
    BLAKE      2850 So, its not the rownum you would want to change, but the order by.
    -Arun

  • Newbie Select * FROM table  where IF Numeric  else  something else

    I have a text on a web page. If one can enter an EMPLOYID ( like 55 ) or
    lastname like 'SMITH'.
    I tried using INSTR and Substr but no avail.
    Select *
    from Atable
    WHERE
    IF SUBSTR(myfield,1,1)="0" OR
    IF SUBSTR(myfield,1,1)="1" OR
    etc.
    EMPID=to_number(myfield)
    ELSE
    Upper(Lastname) like Upper(myfield)
    Suggestions?
    TIA
    Steve

    Yes myfield could be either "55" OR it could be "SMITH"
    Otherwise I would have to have 2 textboxes on the web page.
    One for EmployeeID and one for lastname.
    Thanks.
    Steve

  • SELECT * FROM table WHERE id NOT IN?  Help with statement.

    Hi,
    Two tables. Orders (orderID = PK) and Paid Orders (orderID =
    FK)
    I want to display a recordset of orders from the Orders table
    where the
    order ID doesn't appear in the Paid Orders table.
    I have tried something like this:
    SELECT *
    FROM dbo.tblOrders
    WHERE orderID NOT IN ( SELECT TOP 100 PERCENT
    tblPaidOrders.orderID FROM
    dbo.tblPaidOrders )
    ...no joy with that though. Would appreciate some guidance.
    Thank you.
    Regards
    Nath.

    Hi Nancy,
    Before I begin that, can I ask if there is an issue with the
    OR?
    I need it to be:
    (orderID IN (SELECT qryPaidOrders.orderID FROM qryPaidOrders)
    ORDER BY
    orderdate ASC) AND ((customerid = MMColParam1) OR (vanopID =
    MMColParam2))
    MMColParam1 is exactly the same as MMColParam but, for some
    reason
    unbeknowns to me, DW8.0.2 won't allow me to use it twice.
    That's neither
    here nor there though, as creating a 2nd variable
    (MMColParam2) solves that
    particular issue.
    Do I need additional ( ) anywhere considering it is an OR
    though?
    Thanks.
    nath.
    "Nancy *Adobe Community Expert*" <[email protected]>
    wrote in message
    news:[email protected]...
    >I would think so .. now that you have the core statement
    working .. try
    >adding the other portions. Put the main statement in ( )
    and add the
    >others. Like this:
    >
    > SELECT *
    > FROM dbo.qryOrders
    > WHERE (orderID IN (SELECT qryPaidOrders.orderID FROM
    qryPaidOrders)
    > ORDER BY orderdate ASC) AND (customerid = MMColParam1)
    AND (vanopID =
    > MMColParam2)
    >
    > See what that gives you and fiddle with those till you
    get what you want.
    >
    >
    > --
    > Nancy Gill
    > Adobe Community Expert
    > BLOG:
    http://www.dmxwishes.com/blog.asp
    > Author: Dreamweaver 8 e-book for the DMX Zone
    > Co-Author: Dreamweaver MX: Instant Troubleshooter
    (August, 2003)
    > Technical Editor: DMX 2004: The Complete Reference, DMX
    2004: A
    > Beginner's
    > Guide, Mastering Macromedia Contribute
    > Technical Reviewer: Dynamic Dreamweaver MX/DMX: Advanced
    PHP Web
    > Development
    >
    >
    >
    >
    > "tradmusic.com" <[email protected]> wrote
    in message
    > news:[email protected]...
    >> Hi,
    >>
    >> After a bit of twiddling, I changed the statement to
    this:
    >>
    >> SELECT *
    >> FROM dbo.qryOrders
    >> WHERE orderID IN (SELECT qryPaidOrders.orderID FROM
    qryPaidOrders)
    >> ORDER BY orderdate ASC
    >>
    >> ...and it displays only those records who appear in
    the Paid Orders
    >> table. If I change this to NOT IN, it displays only
    the orders in the
    >> Orders table.
    >>
    >> Ideal, but I need to apply the customerID and
    vanopID variables....is
    >> that possible within this one statement?
    >>
    >> Really appreciate the help,
    >> Regards
    >> Nath.
    >>
    >> "Nancy *Adobe Community Expert*"
    <[email protected]> wrote in message
    >> news:[email protected]...
    >>> You've added to it since the first post. Take
    out the customerID and
    >>> vanopID parts and try focusing on just the
    orderID part. Get that
    >>> working first.
    >>>
    >>> I would try seeing if you can select those
    orderID's that are IN the
    >>> subquery first .. that would see whether or not
    the problem is the NOT
    >>> .. which should work .. but let's see first
    whether the culprit is the
    >>> query structure or not. See if you can select
    the orderID's that are in
    >>> the paid orders table from the main query.
    >>>
    >>>
    >>> --
    >>> Nancy Gill
    >>> Adobe Community Expert
    >>> BLOG:
    http://www.dmxwishes.com/blog.asp
    >>> Author: Dreamweaver 8 e-book for the DMX Zone
    >>> Co-Author: Dreamweaver MX: Instant
    Troubleshooter (August, 2003)
    >>> Technical Editor: DMX 2004: The Complete
    Reference, DMX 2004: A
    >>> Beginner's
    >>> Guide, Mastering Macromedia Contribute
    >>> Technical Reviewer: Dynamic Dreamweaver MX/DMX:
    Advanced PHP Web
    >>> Development
    >>>
    >>>
    >>> "tradmusic.com"
    <[email protected]> wrote in message
    >>> news:[email protected]...
    >>>> Hi Nancy,
    >>>>
    >>>> Have just tried that, but it is still
    displaying records whose orderID
    >>>> is also in a record in the Paid Orders
    table?
    >>>>
    >>>> I've got:
    >>>>
    >>>> SELECT *
    >>>> FROM dbo.qryOrders
    >>>> WHERE customerID = MMColParam OR vanopID =
    MMColParam1 AND orderID NOT
    >>>> IN (SELECT qryPaidOrders.orderID FROM
    qryPaidOrders)
    >>>> ORDER BY orderdate ASC
    >>>>
    >>>> Hope you can help.
    >>>> Thanks. :o)
    >>>> Nath.
    >>>>
    >>>>
    >>>> "Nancy *Adobe Community Expert*"
    <[email protected]> wrote in message
    >>>> news:[email protected]...
    >>>>> Why couldn't your inner query just be
    SELECT orderID from
    >>>>> dbo.tblPaidOrders? Wouldn't the top 100%
    be all of them?
    >>>>>
    >>>>>
    >>>>> --
    >>>>> Nancy Gill
    >>>>> Adobe Community Expert
    >>>>> BLOG:
    http://www.dmxwishes.com/blog.asp
    >>>>> Author: Dreamweaver 8 e-book for the DMX
    Zone
    >>>>> Co-Author: Dreamweaver MX: Instant
    Troubleshooter (August, 2003)
    >>>>> Technical Editor: DMX 2004: The Complete
    Reference, DMX 2004: A
    >>>>> Beginner's
    >>>>> Guide, Mastering Macromedia Contribute
    >>>>> Technical Reviewer: Dynamic Dreamweaver
    MX/DMX: Advanced PHP Web
    >>>>> Development
    >>>>>
    >>>>>
    >>>>> "tradmusic.com"
    <[email protected]> wrote in message
    >>>>>
    news:[email protected]...
    >>>>>> Hi,
    >>>>>>
    >>>>>> Two tables. Orders (orderID = PK)
    and Paid Orders (orderID = FK)
    >>>>>> I want to display a recordset of
    orders from the Orders table where
    >>>>>> the order ID doesn't appear in the
    Paid Orders table.
    >>>>>>
    >>>>>> I have tried something like this:
    >>>>>>
    >>>>>> SELECT *
    >>>>>> FROM dbo.tblOrders
    >>>>>> WHERE orderID NOT IN ( SELECT TOP
    100 PERCENT tblPaidOrders.orderID
    >>>>>> FROM dbo.tblPaidOrders )
    >>>>>>
    >>>>>> ...no joy with that though. Would
    appreciate some guidance. Thank
    >>>>>> you.
    >>>>>>
    >>>>>> Regards
    >>>>>> Nath.
    >>>>>>
    >>>>>
    >>>>>
    >>>>
    >>>>
    >>>
    >>>
    >>
    >>
    >
    >

  • Select * from TABLE where Filed like pa_input.

    Hello,
    the following works fine
    select * from ZTABLE INTO wa_myarea WHERE myfield LIKE 'a%'.
    Now I don't want to hard code the selection criteria for myfield, but let the user select one, so I did:
    parameters pa_input type mytype.
    select * from ZTABLE INTO wa_myarea WHERE myfield LIKE pa_input.
    If the user enters now for example a% everything works again fine. But I assume that a user rather would enter a* for a wild card search and that doesn't work. Do I have to manually replace all * in my variable with % before I run the select statement? I hope not... What would be the best way?
    Thanks.

    Moderator message - Please do not ask basic questions - thread locked
    Rob

  • Select from table where field contains the first 3 character

    The value of the field contains leading zeros like 0000000123, 0000001123, 0000011123.
    Now we need to check the table for entries that contains the first three characters excluding the zeros.
    If we are looking for '123' then we should be retrieving 0000000123 and not 0000001123 or 0000011123.
    Is there a way to get that value in SQL statement with only the exact result?
    Thanks.

    P156550 wrote:>
    > We've tried to use LIKE in our SQL statements and filtered it but there are a bunch of data and we want to get the exact row to improve the performance.
    Hello Adjhan,
    Yes, you need not use LIKE.
    You can use CONVERSION EXIT. I see that the length of your data is CHAR10.
    So try to use the code i have suggested & revert back if any doubts.
    @Soumyaprakash:
    If read the original post carefully, the OP has said:
    If we are looking for '123' then we should be retrieving 0000000123 and not 0000001123 or 0000011123.
    So LIKE does not come into the picture.
    Good Luck,
    Suhas

  • Select * from Table where field1 = (select max(field1) from Table2)  counterpart

    Post Author: JuneCruz
    CA Forum: Data Connectivity and SQL
    These is my table  with 3 fields NFstCol, NsndCol, and NtrdCol
    NFstCol NSndCol NTrdCol -
    1      One      12      One      13      One      14      Two      15      Two      16      Two      17      One      28      One      29      One      210    One      311    One      312    One      316    Two      217    Two      218    Two      219    Four    NULL20    Four    NULL21    Four    NULL
    Now I want to display the records all records that have the maximum ntrdcol group by nsndcolso the output should be.          NfstCol     NtrdColOne         10         3         11         3         12         3
    Two          16         2         17         2         18         2
    Four           19        null          20        null          21        null
    Can this be done without using view and command as source for the database.thanks.

    Post Author: JuneCruz
    CA Forum: Data Connectivity and SQL
    Hi Jagan, all;
       Thanks for the reply.  It works.  Now Im grouping again my reports based on status.
        my records would be.
             FstCol              NsndCol             Status
            1                   One              Inactive        2                   One              Active        3                   One              Active
      My  first group would be Status , then by NsndCol
      However my report shows             Active             FstCol    NsndCol             3            One       Inactive             1            One
      but I want only record number 3 having 3 as the max id for One, I just want to ignore about the Status but I need to group my records based on status  also
                 FstCol    NsndCol             3            One
    Thanks,

  • Select data from table where field is initial

    I have table that has 10 million records.
    I want to select data from this table where certain date field is blank.
    *SELECT * FROM table*
    INTO TABLE internal table
    WHERE PSTNG_DATE = BLANK.
    Does anybody know how to select data from data base table when certain field is blank.
    I cont select all data once and delete which i dont want, the table is big, it will blow up app server.
    thanks in advance,
    Sachin
    Moderator: Pls do not lock the posting instead provide me the link, its disrespecting.

    Respect the forum rules and common sense, and you will be respected.
    "how to select data from a database table when the field is blank" is very basic, and basic questions will be locked, because they have been asked many times and you can find the answer yourself with a little effort. There is nothing disrespectful about it.
    Thread locked.
    Thomas

  • CREATE TABLE A AS SELECT * FROM B WHERE 1 = 2'-Queries

    Guys,
    I request your guidance in the effect of Create table statement below:
    CREATE TABLE A AS SELECT * FROM B WHERE 1 = 2';
    Question:
    1)What would be the PCTFREE value for table A-Would it inherit PCTFREE from table B?
    2) Will table A be created with LOGGING or NO LOGGING?-Will it iinhert the same from table B?
    3) What would be the degree of parallelism of table A?-Will it inherit the DOP from B?
    Thank you very much for your guidance in advance..
    Regards,
    Bhagat

    1 => it will inherit from the default value
    2 => same thing
    3 => same thing
    The create table as select will only copy the structure of the source table and can copy the datas too. That is all.

  • Getting an error while selecting from table having CLOB column.

    Hi All,
    I have below table created in My oracle database version Oracle Database 11g Enterprise Edition Release 11.2.0.1.0.
    CREATE TABLE my_clob -- Dummy table created
    (DataBody CLOB);
    Current Database Character set - WE8MSWIN1250.
    On the front end of my application, I have one form through which I can save/edit data in the above table. If I'm creating one new entry in the above table then it first check with existing record to avoid the duplicate entry and the this point application create the below select statement on the above table and return the error "ORA-00932: inconsistent data types: expected - got CLOB".
    I can not change the sql statement.
    SELECT * FROM my_clob WHERE databody IS NULL OR databody ='';
    Even when I run the same statement on my DB server I’m getting the same error. Shown below
    SQL> SELECT * FROM my_clob WHERE databody IS NULL OR databody ='';
    SELECT * FROM my_clob WHERE databody IS NULL OR databody =''
    ERROR at line 1:
    ORA-00932: inconsistent datatypes: expected - got CLOB
    SQL>
    Is there anything with OraOLEDB which causing this error? Please help me out to get rid of this error.
    Thanks,
    Santosh

    You cannot compare directly a CLOB column with a VARCHAR2 column. In your case you don't need to do such comparison because Oracle consider zero length strings as null values:
    SQL> create table my_clob(data int, databody clob);
    Table created.
    SQL> insert into my_clob values(1, null);
    1 row created.
    SQL> insert into my_clob values(2, '');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from my_clob where databody is null;
          DATA
    DATABODY
             1
             2About null values in Oracle, please read http://docs.oracle.com/cd/E11882_01/server.112/e26088/sql_elements005.htm#SQLRF30037.

  • Is it possible to ... SELECT * FROM my_table WHERE ssn IN (..arraylist..) ?

    Hi, I have a quick question I hope someone can help me with. I'm a student and what I'm looking for should be easy but I can't find any information on it.
    Here's my code, it's probably self-explanatory but to clarify I'm trying to get a list of "Captains" in the order of who has the most wins.
    The problem is that the database tables have thousands of "Captains" and I'm only supposed to look at 200 specific "Captains" which have their ssn in a specific arraylist and then return the top 80 "Captains" from that selection.
    Something like this...
    SELECT first 80 E.name, L.ssn, COUNT(L.wins) as Wins
    FROM log L, employees E
    where type matches "[Captain]"
    and E.ssn = L.ssn
    and L.ssn IN (...arraylist...) // How do I loop through the arraylist but still return a list of the top 80 winners?
    group by E.name, L.ssn
    order by Wins desc;
    Should I start by taking the list of social security numbers from the arraylist and insert them into a temporary table and then use that temporary table to base my selection on?
    For example:
    int rows = 0;
    PreparedStatement ps = conn.prepareStatement("INSERT INTO TEMP captainsTemp (ssn) VALUES(?)");
    Iterator i = myArrayList.iterator();
    while (i.hasNext())
         // Set the variables
         for (int pos = 1; pos <= 63; pos++)
              String s = (String)i.next();
              ps.setString(pos,s);
         // insert a row
         rows += ps.execute();
    ...and then below that I could use
    "SELECT * FROM captains
    WHERE ssn IN (SELECT * FROM captainTemp)..."
    This looks like an ugly solution and I'm not sure if it works, sessionwise..
    Everything's written in Java and SQL.
    If you have any thoughts on this I would be most grateful.
    I should add that this is NOT a school assignment but something I'm trying to figure out for my work...
    Many thanks,
    sincerely,
    JT.

    hi,
    Ignore my previous response. Try out this one. It should help you.
    Lets take the example of EMP table (in Oracle's SCOTT Schema). The following is the description of the table.
    SQL> desc emp
    Name Null? Type
    EMPNO NOT NULL NUMBER(4)
    ENAME VARCHAR2(10)
    JOB VARCHAR2(9)
    MGR NUMBER(4)
    HIREDATE DATE
    SAL NUMBER(7,2)
    COMM NUMBER(7,2)
    DEPTNO NUMBER(2)
    SQL> select ename from emp;
    ENAME
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    JAMES
    FORD
    MILLER
    Say, the ArrayList contains 3 names CLARK,KING & MILLER. You want to loop through the ArrayList for the ENAME values.
    First construct a string like below from the ArrayList.
    "ename in 'CLARK' OR ename in 'KING' or ename in 'MILLER'";
    Append this string to the normal SELECT Query
    Query :
    select ename from emp where ename in 'CLARK' OR ename in 'KING' or ename in 'MILLER'
    Here you get the desired output & thats pretty fast because you just do it once !!!
    SQL> select ename from emp where ename in 'CLARK' OR ename in 'KING' or ename in 'MILLER';
    ENAME
    CLARK
    KING
    MILLER
    you can extend this to your Query also.
    thanks,
    Sriram

Maybe you are looking for

  • Need help for FILE_get_name

    1) For my senario I have to use the function module FILE_GET_NAME. Before using this function module do I configure any thing in 'FILE' transaction. If it is required please let me know the procedure to use this function module

  • How can I see date and time of a imovie event (new imovie 10.0.4). Thank you for your answer and greetings from switzerland.

    How can I see Date and Time of an event in iMovie 10.0.4? Thank you for your answer. greetings from Switzerland

  • Repair Permissions this is the usual errors...

    Hello, Would anyone be able to tell me why, and how to correct these errors that constantly show each time I go into Utilities and run the check? I have no idea why these constantly happen.... Thank you in advance, Neil Schwartz Howell, NJ Verifying

  • Pegged Requirement Report

    Hi All, I am developing a report for pegged requirement, in that my requirement is , I want to display the component number , receipt number and its quantity ( Similar to the results that are displayed  in MD04 ). I am passing header component and th

  • Unable to read shared variable in signal express

    Dear all, I am trying to read a shared variable with data type 'Array of Double Waveform' and the signal express gives a network variable error stating "The data type of specified shared variable xxxxxx is not supported". could any one explain why is