Suppose my column name is "psdi", i want to print only numeric rows
psdi
100
10k
103f
456
9o2u
125
931
Required O/P:
psdi
100
456
125
Suppose my column name is "psdi", i want to print only numeric rows
psdi
100
10k
103f
456
9o2u
125
931
Required O/P:
psdi
100
456
125
Here are two simple methods. One looks for letters:
select t.*
from t
where not psdi ~ '[a-zA-Z]'
or for just digits:
select t.*
from t
where not psdi ~ '^[0-9]+$'
Use pattern matching in where clause
'^-?([0-9]+\.?[0-9]*|\.[0-9]+)$'
- This selects all type of values(positive, negative and floating values)
select *
from (
values ('100T')
,('456.5')
,('-65')
,('9879t')
,('454')
) t(a)
where a ~ '^-?([0-9]+\.?[0-9]*|\.[0-9]+)$'
Your query will be
select psdi
from your_table
where psdi ~ '^-?([0-9]+\.?[0-9]*|\.[0-9]+)$'