Howdy,
I'm new here and hope that someone can help me with my issue.
I have a toplist which shows unique lakes (mm) for each user (mycall) in a table that also tracks confirmed lakes (conf = 1). Grouping by mycall and ordering by total gives me the toplist.
Now for my problem. I need the list to also be sorted by the time. The table has a datetime column (tid). I need the date for the latest unique count.
Example table
mycall ,tid, mm, conf
SM6ABC, 2022-04-01 09:00:00, AAAA, 1
SM6ABC, 2022-04-01 09:01:00, AAAB, 1
SM6ABC, 2022-04-01 09:12:00, AAAA, 1
SM6CBA, 2022-04-01 09:10:00, BBBB, 1
SM6CBA, 2022-04-01 09:11:00, AAAA, 1
SM6AAA, 2022-04-01 09:12:00, AAAA, 1
Output should be
SM6ABC, 2 (Last unique data is SM6ABC, 20220401 09:01:00, AAAB, 1)
SM6CBA, 2 (Last unique data is SM6CBA, 2022-04-01 09:11:00, AAAA, 1)
SM6AAA, 1
What I have tried:
MySQL
SELECT mycall, COUNT(DISTINCT mm) AS 'total' FROM KJ_log WHERE mm !='' AND conf = '1' GROUP BY mycall ORDER BY total DESC
This works fine but how do I include the datetime sorting? I tried to add select MAX(tid) but that returns last date for the user.