Sql query to find the last word in a sentence (column)

Hi,
I have to retrieve the last word in a column containing varchar2(text) values.
If anyone knows the query for this kindly share with me.

There's also the option of regular expressions in 10g onwards...
SQL> ed
Wrote file afiedt.buf
  1  with t as (select 'oracle forums is the best resource for oracle intelligence' as l from dual)
  2  select regexp_replace(l, '[[:print:]]* ([^ ]*)$','\1') as l
  3* from t
SQL> /
L
intelligence
SQL>

Similar Messages

  • Sql query to find the balances for a customer account wise.

    Hi,
    Could someone help me with the sql query to find the balances for each customer account wise. This is need to generate the report.
    presently we are using this query, but the output doesnot return the expected result.
    SELECT sum(nvl(ps.acctd_amount_due_remaining,0)) "Balance"
    FROM      ra_cust_trx_line_gl_dist_all gld,
              gl_code_combinations c,
              ar_payment_schedules_all ps,
              RA_CUSTOMER_TRX_ALL rat,
              ra_customers rc
    WHERE      c.CHART_OF_ACCOUNTS_ID = 101
    and gld.code_combination_id = c.code_combination_id
         and rat.CUSTOMER_TRX_ID=gld.CUSTOMER_TRX_ID
         and rat.CUSTOMER_TRX_ID=ps.CUSTOMER_TRX_ID
    and ps.customer_id=rc.customer_id
         and ps.status='OP'
         and ps.gl_date <= :PDATE
         and ps.org_id=:PORGID
         and ps.class in ('GUAR','INV','DM','DEP')
    and c.SEGMENT4=:Account_id
    and ps.customer_id=:Customer_id
    Thanks in advance.
    Kalyan.

    Can someone help us with this.

  • Can anybody provide the SQL query to find the files uploaded in a particular folder?

    Hi All,
    Can anybody provide the SQL query to find the documents (document name) uploaded in a particular folder? While clicking on folder in
    GUI I'm hitting the Timeout error. I would like to find the files uploaded into this folder from SQLPLUS.
    Any help is greatly appreciated.
    With best regards,
    Nevin

    Nevin,
    Be great if we could know the version of Portal. For Rel. 1, here's the query
    select id,masterthingid from wwv_things
    where siteid = &site
    and cornerid = &corner
    &site - Content Area id
    &corner - Folder id
    if you don't know the folder id, use
    select id from wwv_corners where siteid = &site
    and name = &folder
    Hope this helps. I have run into this situation before. Usually, the culprits were
    one of the following:
    1. Junk Characters in description of item (caused due to Copy-Paste)
    2. Special Characters in the File name
    Hi All,
    Can anybody provide the SQL query to find the documents (document name) uploaded in a particular folder? While clicking on folder in
    GUI I'm hitting the Timeout error. I would like to find the files uploaded into this folder from SQLPLUS.
    Any help is greatly appreciated.
    With best regards,
    Nevin

  • SQL Query to find the Notify upon Completion employees

    Hi,
    I am looking for a query to find the names of the employees/users who are notified upon the completion of the Concurrent Programs. I know how to find the concurrent program details but not able to find notify upon completion employees details. Please help me.
    Thanks,
    KM

    Thanks Scott for responding. There is no any custom code. Here is the navigation to reach there:
    System Administrator -> Requests -> View -> Specific Requests -> Open any request ->View Details -> Options -> Notify the following people
    I am looking for the query to find these notified people using SQL Query.Query FND_CONCURRENT_REQUESTS table (NOTIFY_ON_PP_ERROR column) -- http://etrm.oracle.com/pls/et1211d9/etrm_pnav.show_object?c_name=FND_CONCURRENT_REQUESTS&c_owner=APPLSYS&c_type=TABLE
    Thanks,
    Hussein

  • Sql query to find the space in between the sentense

    hi,
    can anybody tell me the query to find the space in between the data
    chandan

    Not sure what you mean, but you might want to take a look at INSTR, like in
    instr (txt, ' ')

  • Sql query to find the scheduled date

    I schedule a job for last Thursday of every month. Based on my current date and time I need the date of my next scheduled run of the job...
    (i.e) If today is 28-march-2012 (Wednesday) my query should return 3/29/12(which is the last thursday of the month)
    If today is 30-march-2012 (Friday) my query should return 4/26/12 (which is the last thursday of next month)
    If today is 29-march-2012 and time is 11:00 AM and i have scheduled a job to run at 12:00 PM of last thursday of every month then my query should return 3/29/12
    If today is 29-march-2012 and time is 1:00 PM then my query should return 4/26/12

    924163 wrote:
    I schedule a job for last Thursday of every month. Based on my current date and time I need the date of my next scheduled run of the job...
    (i.e) If today is 28-march-2012 (Wednesday) my query should return 3/29/12(which is the last thursday of the month)
    If today is 30-march-2012 (Friday) my query should return 4/26/12 (which is the last thursday of next month)
    If today is 29-march-2012 and time is 11:00 AM and i have scheduled a job to run at 12:00 PM of last thursday of every month then my query should return 3/29/12
    If today is 29-march-2012 and time is 1:00 PM then my query should return 4/26/12may be
    SQL> ed
    Wrote file afiedt.buf
      1  with tmp as
      2  (
      3  select to_date('28-march-2012','DD-month-YYYY') dt from dual union all
      4  select to_date('29-march-2012 11:00:00 AM','DD-month-YYYY HH:MI:SS AM') dt from dual union all
      5  select to_date('29-march-2012 1:00:00 PM','DD-month-YYYY HH:MI:SS AM') dt from dual union all
      6  select to_date('29-march-2012 12:00:00 PM','DD-month-YYYY HH:MI:SS AM') dt from dual union all
      7  select to_date('29-march-2012 11:59:00 AM','DD-month-YYYY HH:MI:SS AM') dt from dual union all
      8  select to_date('30-march,2012','DD-month-YYYY') dt from dual
      9  )
    10  select dt,
    11         case
    12           when Next_day(Add_months(Trunc(dt, 'MM'), 1) - 7, 'thursday') + ( 12 /
    13                24 ) >
    14                dt then Next_day(Add_months(Trunc(dt, 'MM'), 1) - 7, 'thursday')
    15           else Next_day(Add_months(Trunc(dt, 'MM'), 2) - 7, 'thursday')
    16         end new_dat
    17  from   tmp
    18* order  by dt
    SQL> /
    DT                      NEW_DAT
    28-Mar-2012 12:00:00 AM 29-Mar-2012 12:00:00 AM
    29-Mar-2012 11:00:00 AM 29-Mar-2012 12:00:00 AM
    29-Mar-2012 11:59:00 AM 29-Mar-2012 12:00:00 AM
    29-Mar-2012 12:00:00 PM 26-Apr-2012 12:00:00 AM
    29-Mar-2012 01:00:00 PM 26-Apr-2012 12:00:00 AM
    30-Mar-2012 12:00:00 AM 26-Apr-2012 12:00:00 AM
    6 rows selected.
    SQL>

  • SQL Query to find the Delta between 2 rows

    Can the below be possible? If so can you help me writing aSQL Query to do so…
    I have data in spreadsheet which is pulled off from the database (data from more than one table with joins); send it to the different teams. They will check the data n update the spreadsheet if necessary and send it back to me.
    I have to find the changes and update the database from the provided spreadsheet accordingly. Changes can be on different columns on each set of row.
    Example:
    DataFrom
    ServerName
    Branch_Name
    Application_Name
    Server Status
    Application_Status
    App_Environment
    Tier
    SQL Query
    abcdef
    app
    adp
    Deployed
    Deployed
    Production
    silver
    Excel
    abcdef
    app
    adp
    Deployed
    Deployed
    Development
    Bronze
    DataFrom
    ServerName
    Branch_Name
    Application_Name
    Server Status
    Application_Status
    App_Environment
    Tier
    SQL Query
    Hijkl
    app
    adp
    Deployed
    Deployed
    Production
    Gold
    Excel
    Hijkl
    app
    Dep
    Deployed
    Deployed
    Production
    Gold
    DataFrom
    ServerName
    Branch_Name
    Application_Name
    Server Status
    Application_Status
    App_Environment
    Tier
    SQL Query
    Xzy
    app
    Dep
    Deployed
    Deployed
    Production
    Silver
    Excel
    Xzy
    App
    Dep
    Deployed
    Deployed
    Development
    Silver
    Above scenario is an example what I am look to do with sql script? Opinions/queries accepted…
    There are 1200+ rows to compare it manually which is a pain.
    Thanks.

    Columns are different, when the contain multiple distinct values.
    SELECT COUNT(DISTINCT Name) ,
    COUNT(DISTINCT GroupName) ,
    COUNT(*)
    FROM HumanResources.Department;
    Without a concise and complete example (table DDL and sample data insert statements), it's hard to tell what the correct solution could be..
    DECLARE @Sample TABLE ( SetID INT, ServerID INT, ApplicationID INT );
    INSERT INTO @Sample
    VALUES ( 1, 1, 1 ),
    ( 1, 1, 1 ),
    ( 2, 1, 1 ),
    ( 2, 1, 2 ),
    ( 3, 1, 1 ),
    ( 3, 2, 1 );
    WITH Evaluate AS
    SELECT SetID,
    COUNT(DISTINCT ServerID) AS Servers,
    COUNT(DISTINCT ApplicationID) AS Applications
    FROM @Sample
    GROUP BY SetID
    SELECT S.*,
    CASE WHEN E.Servers != 1 THEN 1 ELSE 0 END AS ServersDifferent,
    CASE WHEN E.Applications != 1 THEN 1 ELSE 0 END AS ApplicationsDifferent
    FROM @Sample S
    INNER JOIN Evaluate E ON S.SetID = E.SetID
    ORDER BY S.SetID;

  • SQL query to find out last login for each database

    Hi everybody,
    I have a view with following columns:
    DatabaseSid, lastLogin, firstLogin.
    I want to now the newest last_login date for every database.
    SID First Login Last Login
    e.g. Database1, 11.11.2011, 01.12.2011
    Database1, 01.04.2012, 01.05.2012
    Database3, 03.03.2004, 03.06.2005
    Database 3 07.09.2012, 12.10.2012
    How can I do a query to find out for eacht DB (DB1, DB2 and so on) the Last_Login Date?
    Thank you in advance
    Steve

    Steve wrote:
    Hi everybody,
    I have a view with following columns:
    DatabaseSid, lastLogin, firstLogin.
    I want to now the newest last_login date for every database.
    SID First Login Last Login
    e.g. Database1, 11.11.2011, 01.12.2011
    Database1, 01.04.2012, 01.05.2012
    Database3, 03.03.2004, 03.06.2005
    Database 3 07.09.2012, 12.10.2012
    How can I do a query to find out for eacht DB (DB1, DB2 and so on) the Last_Login Date?
    Thank you in advance
    SteveI'm curious as to how you collect this information from multiple databases into one database, and of what value the data is once you have it.

  • Sql query to find out last update of 6 hours

    i have table emp . for Exp.
    create table emp
    (empno number(5),
    ename varchar2(20),
    last_update date );
    Now i want the all data which is update in last 6 hours

    Assuming an INDEX, WHERE Last_Update > SysDate - 6/24; is better and clearer.
    It is better because it allows INDEX use. That is because it does not manipulate the COLUMN value.
    It is clearer because it clearly states what we want, the records where Last_Update is after a value of six hours before. In the other query, we are checking for records where Last_Updated minus six hours is after current time. Personally, I find that harder to follow.
    SQL> CREATE TABLE Emp(EmpNo NUMBER(5), EName VARCHAR(20), Last_Update DATE);
    Table created.
    SQL> CREATE INDEX Emp_Last_Update ON Emp(Last_Update);
    Index created.
    SQL> INSERT INTO Emp(Empno, EName, Last_Update) SELECT 626, 'user626892', SysDate - Level FROM Dual CONNECT BY Level <= 10000;
    10000 rows created.
    SQL> exec DBMS_STATS.Gather_Schema_Stats(NULL);
    PL/SQL procedure successfully completed.
    SQL> EXPLAIN PLAN FOR SELECT * FROM Emp WHERE SysDate - Last_Update <= 6/24;
    Explained.
    SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3956160932
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |   500 | 11500 |    15  (14)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| EMP  |   500 | 11500 |    15  (14)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter(SYSDATE@!-"LAST_UPDATE"<=.25)
    13 rows selected.
    SQL> EXPLAIN PLAN FOR SELECT * FROM Emp WHERE Last_Update > SysDate - 6/24;
    Explained.
    SQL> SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);
    PLAN_TABLE_OUTPUT
    Plan hash value: 38459689
    | Id  | Operation                   | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |                 |     1 |    23 |     3   (0)| 00:00:01 |
    |   1 |  TABLE ACCESS BY INDEX ROWID| EMP             |     1 |    23 |     3   (0)| 00:00:01 |
    |*  2 |   INDEX RANGE SCAN          | EMP_LAST_UPDATE |     1 |       |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       2 - access("LAST_UPDATE">SYSDATE@!-.25)
    14 rows selected.

  • The last word always shifts to the next line when published?

    When I layout the page in iweb08 it looks great, when I publish it the last word in a sentence (no matter how short the sentence) is on a separate line. I have tried everything to change this but no luck.
    http://www.thestraydogsrock.com is the website. The bottom blue area where it says "August 16, 2009......." is the problem line. This is a standard iweb template.

    don21480 wrote:
    When I layout the page in iweb08 it looks great, when I publish it the last word in a sentence (no matter how short the sentence) is on a separate line. I have tried everything to change this but no luck.
    What I can think of is pretty obvious so you've probably already tried it.
    In case you haven't: just make the text box bigger. Slide the right side more to the right.
    Or is there a ghost image knocking into it somehow?
    http://www.thestraydogsrock.com is the website.
    The site looks great!
    Wondering myself - how did you do those audio play things, with the horseshoes in them?

  • How to find the last execute query

    Hi, Is there a way to find the last executed query of report?
    Thanks
    Aali
    Edited by: aali on 22-Feb-2010 06:39

    Hi,
    if you hold the necessary privileges, you might find the SQL in the shared pool:
    select last_active_time, parse_calls, disk_reads, buffer_gets, cpu_time, end_of_fetch_count, executions, plsql_exec_time, sql_text
    from V$SQLSTATS
    where sql_text like '% some distinctive string %'
    order by last_active_time desc;if you insert some meaningful string in form of comment inside the query itself, say /* report #1 on page 3 */
    you may be able to track it down more easily.
    select last_active_time, parse_calls, disk_reads, buffer_gets, cpu_time, end_of_fetch_count, executions, plsql_exec_time, sql_text
    from V$SQLSTATS
    where sql_text like '% report #1 on page 3  %'
    order by last_active_time desc;Bye
    Flavio
    http://oraclequirks.blogspot.com

  • Query to find the memory of database in oracle,sql

    Hi All,
    Please let me know the query to find the memory of database in oracle,sql.
    Thanks,
    sajith

    How do I find the overall database size?
    The biggest portion of a database's size comes from the datafiles. To find out how many megabytes are allocated to ALL datafiles:
    select sum(bytes)/1024/1024 "Meg" from dba_data_files;
    To get the size of all TEMP files:
    select nvl(sum(bytes),0)/1024/1024 "Meg" from dba_temp_files;
    To get the size of the on-line redo-logs:
    select sum(bytes)/1024/1024 "Meg" from sys.v_$log;
    Putting it all together into a single query:
    select a.data_size+b.temp_size+c.redo_size "total_size"
    from ( select sum(bytes) data_size
    from dba_data_files ) a,
    ( select nvl(sum(bytes),0) temp_size
    from dba_temp_files ) b,
    ( select sum(bytes) redo_size
    from sys.v_$log ) c;
    Another query ("Free space" reports data files free space):
    col "Database Size" format a20
    col "Free space" format a20
    select round(sum(used.bytes) / 1024 / 1024 ) || ' MB' "Database Size"
    , round(free.p / 1024 / 1024) || ' MB' "Free space"
    from (select bytes from v$datafile
    union all
    select bytes from v$tempfile
    union all
    select bytes from v$log) used
    , (select sum(bytes) as p from dba_free_space) free
    group by free.p
    This is what I use :P From http://www.orafaq.com/wiki/Oracle_database_FAQ#How_do_I_find_the_overall_database_size.3F

  • Query to find the user is having access to sql server DB

    Hi,
    Please help me in this.
    Query to find the whether the user is having access to sql server DB.
    Cheers,
    sajith

    TUBBY_ORCL?Select 1 from dual where 'ORACLE' = 'SQL SERVER';
    no rows selected
    Elapsed: 00:00:00.01

  • Write the sql query to find largest value in row wise without using   great

    write the sql query to find largest value in row wise without using
    greatest fuction?

    Another not so good way, considering you want greatest of 4 fields from a single record:
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (Select 100 col1,200 col2,300 col3,400 col4 from dual
      2  union select 500,600,700,800 from dual
      3  union select 900,1000,1100,1200 from dual
      4  union select 1300,1400,1500,1600 from dual
      5  union select 1700,1800,1900,2000 from dual
      6  union select 2100,2200,2300,2400 from dual
      7  union select 2800,2700,2600,2500 from dual
      8  union select 2900,3000,3100,3200 from dual)
      9  SELECT (CASE WHEN col1 > col2 THEN col1 ELSE col2 END) Max_value
    10  FROM
    11  (SELECT (CASE WHEN col1_col2 > col2_col3 THEN col1_col2 ELSE col2_col3 END) col1,
    12         (CASE WHEN col2_col3 > col3_col4 THEN col2_col3 ELSE col3_col4 END) col2,
    13         (CASE WHEN col3_col4 > col4_col1 THEN col3_col4 ELSE col4_col1 END) col3
    14  FROM
    15  (SELECT (CASE WHEN col1 > col2 THEN col1 ELSE col2 END) col1_col2,
    16         (CASE WHEN col2 > col3 THEN col2 ELSE col3 END) col2_col3,
    17         (CASE WHEN col3 > col4 THEN col3 ELSE col4 END) col3_col4,
    18         (CASE WHEN col4 > col1 THEN col4 ELSE col1 END) col4_col1
    19* FROM t))
    SQL> /
    MAX_VALUE
           400
           800
          1200
          1600
          2000
          2400
          2800
          3200
    8 rows selected.
    SQL> Edited by: AP on Sep 21, 2010 6:29 AM

  • Function to find the Last Date of Month One Year Ago - RETURNS ERROR

    I've written sql code which takes a date and finds the Last Day of the Month one year ago. For example,  it takes the date '2015-04-17' and returns the date '2014-04-30'. The code works fine in a query. Now I'm trying to turn this into a function. However,
    when I try to create the function I get the error:
    Operand type clash: date is incompatible with int
    Why is this error being returned?
    Here is my function:
    CREATE FUNCTION dbo.zEOM_LY_D(@Input Date)
           RETURNS date
    AS
    BEGIN;
      DECLARE @Result date;
      SET @Result =  convert(DATE, DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,dateadd(m, -11, @Input)+1),0)),101)
        RETURN @Result;
    END;
    Thanks for any help you can give.
                     

    Stan,
    Thanks very much- that does the trick. I should have said I am using SQL 2008 so EOMONTH is not available to me. I still don't get why I got an error though, since I was treating a date like a date and not like an int.
    Thanks, John
    I think i found the issue but i do not know why it is causing the issue. i think may be the way dates are treated/stored internally..i think dates are stored as no of days after 0001/01/01 but cannot see how this cwould effect..may be somebody else can through
    some light..... 
    if you make it as datetime it will work,
    if you leave it as date - eliminate adding 1...  you should prefer to use dateadd to add/substract dates.
    try this to understand..
    --removed the +1 in the code
    declare @input date
    set @input ='20150503'
    select
    convert(DATE, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,dateadd(m, -11, @Input)),0)),101)
    go
    --made the datatype as datetime
    declare @input datetime
    set @input ='20150503'
    select
    convert(DATE, DATEADD(s,-1,DATEADD(mm,DATEDIFF(m,0,dateadd(m, -11, @Input)+1),0)),101)
    Hope it Helps!!

Maybe you are looking for

  • LDAP lookup in Calendar?

    Does Calendar have the capability to search LDAP when I'm trying to add someone in the invite?

  • Printing in Multiple Users

    I just replaced an Epson network printer (where everything worked well) with a Brother 2070N laser printer. I am running OS 9.2 on a small networks of iMacs in my classroom. All print fine from the Administrator mode but none will print from Student

  • [Flex 4] calculate component width/height inline or with bindable function

    What I want to achive is something like these two examples (it doesn't work, it's just the idea): 1) Inline <s:Group id="main" width="100%" height="100%" minWidth="950" minHeight="650">      <s:Group width="100%" height="{if (main.height < main.minHe

  • I lost my music on my phone when I synced it to my laptop

    I Just synced my iPhone 4S to my laptop and when it was finished all my music was gone on my phone. Everything else was still on it. It was my daughters phone and already had a lot of music on it some of it was purchased and some was put on from fros

  • Import Mail from Apple Mail to Entourage Failed

    HI all: Got frustrated with Apple Mail due to addressbook and Ical. Just don't like the format. So did file-import from apple mail- and nothing came over. How else should I be doing this?