[英]What sql formula am I missing?
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?我正在尝试将名称和它出现在两个单独列中的次数分组?
Try:尝试:
select name , count(checkinpk)
.....
group by name , count(checkinpk)
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.