Mr Asker
Mr Asker

Reputation: 2380

Get the number of the records without duplicating

I am trying to get the number of stop_name in the behaviour table without duplicating records but I am getting this error below:

So if I have 1 records with the stop_name alex alley and 3 records with the stop_name John alley I want to get the result 2. How can I fix it?

Query:

select stop_name DISTINCT
     , count(*) as totalCount
FROM behaviour
where mac = '10:A5:D0:06:C6:E9'

But I am getting the error:

check the manual that corresponds to your MySQL server version for the right syntax to use near 'DISTINCT, count(*) as totalCount FROM behaviour where mac = '10:A5:D0:06:C6:E9'

Upvotes: 0

Views: 36

Answers (1)

potashin
potashin

Reputation: 44581

Try the following:

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

Upvotes: 3

Related Questions