我的查询哪个分组依据效果很好
select uid,count(*) from user_details where uid <> '' group by uid
尝试通过以下方式转换为分区 我的分区查询不符合预期
select uid,(count(uid) OVER (
PARTITION BY uid
)) counts from user_details where uid <> ''
无错误消息输出不正确。
uid, Count As |
Dates_not_found, 1,192 |
Dates_not_found, 1,192 |
答案 0 :(得分:1)
使用DISTINCT
:查询会将计数结果的输出写入每一行。如果从中获得唯一的行,则需要使用DISTINCT
来获得没有重复的结果。
SELECT DISTINCT uid,(count(uid) OVER (PARTITION BY uid)) Counts
FROM user_details
WHERE uid <> ''