Rubab
Rubab

Reputation: 27

Filter of records in oracle

I have a sets of records in a table like

xyz_t
abc_y
pqr_12-11-2013
psq_1
App_tq2
xyzq_12-10-2014
lpqs_14-09-2012
llyt_23-09-2011
bytx_2
prdtc

I want output

pqr_12-11-2013
xyzq_12-10-2014
lpqs_14-09-2012
llyt_23-09-2011

I mean only those records which has date is suffix.

Thanks in advance.

Upvotes: 2

Views: 37

Answers (2)

Multisync
Multisync

Reputation: 8797

select s from t 
where regexp_like(s, '_[[:digit:]]{1,2}-[[:digit:]]{1,2}-[[:digit:]]{4}$');

[:digit:] - any digit (you can also use \d)

{4} - four times

{1,2} - one or two times

$ end of the string (by default the first carriage return is interpreted as the end)

Upvotes: 2

ntalbs
ntalbs

Reputation: 29448

Use regular expression:

select your_column_name
from your_table
where REGEXP_LIKE(your_column_name, '.*\d{2}-\d{2}-\d{4}$')

Upvotes: 1

Related Questions