I have a table named loginData:
x
userName timestamp
abc '2007-01-01 12:00:12 AM'
def '2021-01-01 12:09:12 AM'
abc '2021-01-01 12:40:12 AM'
abcde '2021-01-01 12:44:12 AM'
From this table I want to query the data in such a way that It doesn’t count duplicates. I want to get data like this:
userLoggedIN - 3
Considering abc
has logged in twice to count it as one. How to do this?
Advertisement
Answer
You can use count(distinct)
:
select count(distinct userName)
from loginData;