Home > Enterprise >  Count values in column that have only letters
Count values in column that have only letters

Time:02-18

How Can I count rows in column where values have only letters ? For exmaple if I have this table:

| ID | Age | FULL_NAME |
|:---- |:------:| -----:|
| 0  | 23    | Jason12 |
| 1  | 11    | SamOG. |
| 2  | 57    | Alexx |

And when I run the query i want to get something like this:

| Numerator | Denominator | 
|:---- |:------:| 
| 1  | 3    |

Numerator are the rows where value is only build with letters and Denominator is count(*). Let's say that my DB name is CUSTOMERS. I use Teradata SQL Assistant. Any ideas how I can do it ? Any help would be greatly appreciated!

CodePudding user response:

use REGEXP_INSTR() like below

select sum(case when REGEXP_INSTR(FULL_NAME,'[0-9]')<>0 then 1 else 0 end)
as Numerator
 ,count(1) as Denominator from table_name
  • Related