获取记录的数量而不重复

时间:2015-06-24 21:35:04

标签: mysql sql

我试图在行为表中获取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'

1 个答案:

答案 0 :(得分:3)

尝试以下方法:

select count(distinct stop_name) as totalCount
from behaviour
where mac = '10:A5:D0:06:C6:E9'