New answers tagged distinct
0
votes
Selecting a count of distinct logins per day
select activitytime,sum(case when rk = 1 then 1 else 0 end) unique_users_count
from
(
select activitytime,[user_id],rank() over(partition by [user_id] order by activitytime) rk
from @Activity
) k
...
Top 50 recent answers are included
Related Tags
distinct × 144postgresql × 48
sql-server × 30
mysql × 30
select × 26
group-by × 23
count × 19
join × 14
oracle × 11
query × 10
query-performance × 9
performance × 8
order-by × 8
greatest-n-per-group × 8
postgresql-performance × 7
index × 6
aggregate × 6
sum × 6
ms-access × 4
subquery × 4
sql-server-2008-r2 × 3
t-sql × 3
optimization × 3
oracle-11g-r2 × 3
mysql-5.7 × 3