我试图在行为表中获取stop_name的数量而不重复记录,但我收到以下错误:
因此,如果我有一个带有stop_name alex alley
的记录和带有stop_name John alley
的3条记录,我想得到结果2
。
我该如何解决?
查询:
select stop_name DISTINCT
, count(*) as totalCount
FROM behaviour
where mac = '10:A5:D0:06:C6:E9'
但我收到错误:
检查与您的MySQL服务器版本相对应的手册,以便使用接近' DISTINCT的正确语法,将count(*)作为totalCount FROM行为,其中mac =' 10:A5:D0:06:C6 :E9'
答案 0 :(得分:3)
尝试以下方法:
select count(distinct stop_name) as totalCount
from behaviour
where mac = '10:A5:D0:06:C6:E9'