select substring(page_type,1,7) as page_type, visiturl, count(*) as count_num from law where visiturl like '%faguizt%' and page_type like '%199%' ;改成sparksql
时间: 2024-03-05 17:55:01 浏览: 146
PHP中substr_count()函数获取子字符串出现次数的方法
可以将该SQL语句转换成Spark SQL语句如下:
```
SELECT SUBSTRING(page_type, 1, 7) AS page_type, visiturl, COUNT(*) AS count_num
FROM law
WHERE visiturl LIKE '%faguizt%' AND page_type LIKE '%199%'
GROUP BY SUBSTRING(page_type, 1, 7), visiturl;
```
在Spark SQL中,GROUP BY子句中的所有列都必须在SELECT子句中指定,因此需要将SUBSTRING(page_type, 1, 7)和visiturl都包含在SELECT子句中。
阅读全文