-1

I need to find out the busiest location by check in for a query.

select name
from checkin join location on checkin.locid = location.LocID
order by name 

This query gives me the result but I cannot figure how to group it by numbers. If I put count (distinct name) it gives a weird result and if I group by name it does not give me the numbers

I am trying to group the names and the amount of times it has come in two separate columns?

Locations

tadman
  • 208,517
  • 23
  • 234
  • 262
Vij
  • 59
  • 5

2 Answers2

2

Try:

select name , count(checkinpk)
.....
group by name , count(checkinpk)
tadman
  • 208,517
  • 23
  • 234
  • 262
0

You can try below:

select name, COUNT(C.LocID) as Checkin_Count
from location AS L
inner join checkin as C on C.LocID= L.LocID
group by name
order by COUNT(C.LocID) desc