使用 regexp_like 的查询的打印结果
Printing result of a query with regexp_like
我有以单词 point
开头的记录和不以单词 point
开头的记录。
我正在计算每一个有多少,我有这个查询:
select count(*) from tbl
where regexp_like(name, '.*point.*')
上面的查询有效。我想知道如何打印这样的结果:
names_with_point names_without_point
234 120
您可以使用 count_if
:
select count_if(regexp_like(name, '.*point.*')) as names_with_point
, count_if(not regexp_like(name, '.*point.*')) as names_without_point
from dataset
不确定 count_if 是 ANSI SQL 函数。
select count(case when regexp_like(name, '.*point.*') THEN name end) as names_with_point,
count(case when not regexp_like(name, '.*point.*') THEN name end ) as names_without_point
from dataset
我有以单词 point
开头的记录和不以单词 point
开头的记录。
我正在计算每一个有多少,我有这个查询:
select count(*) from tbl
where regexp_like(name, '.*point.*')
上面的查询有效。我想知道如何打印这样的结果:
names_with_point names_without_point
234 120
您可以使用 count_if
:
select count_if(regexp_like(name, '.*point.*')) as names_with_point
, count_if(not regexp_like(name, '.*point.*')) as names_without_point
from dataset
不确定 count_if 是 ANSI SQL 函数。
select count(case when regexp_like(name, '.*point.*') THEN name end) as names_with_point,
count(case when not regexp_like(name, '.*point.*') THEN name end ) as names_without_point
from dataset