我的桌子有很多列 我想在1列上进行分组以获取唯一记录的数量 它有大约6亿卢比的数据
我使用查询
select distinct lower(TITLE) , count(lower(TITLE)) as CountOf
from table_name2
where
((LENGTH(lower(TITLE)) - LENGTH(replace(lower(TITLE), ' ', '')))+1) > 3
HAVING COUNT(lower(TITLE))>1
group by lower(TITLE)
我如何以有效的方式做到这一点,如果Title是"岩石花园区"并且它在TITLE字段中存在4次然后我得到它的计数 - > 4
答案 0 :(得分:0)
你可以试试这个:
select
lower(TITLE) ,
count(lower(TITLE)) as CountOf
from table_name2
where
REGEXP_COUNT ('asdaasd ', '\s')+1 > 3
HAVING COUNT(TITLE)>1
group by TITLE
答案 1 :(得分:0)
这应该可以解决问题:
select TITLE , count(TITLE) as CountOf
from (
select LOWER(title) title
from table_name2) t
where TITLE like '% % % %'
group by TITLE
HAVING COUNT(TITLE)>1