Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Count without including duplicates

$
0
0
I have a php mySQL database which records clients visits to a free advice clinic. There is a ‘matters’ table which, amongst others, has fields:
matterid
clientname
visitdate

I want to get totals from this (between certain dates but that isn’t an issue) but I only want to count a client once no matter how many different matters they have set up.

If I use 'SELECT DISTINCT clientname' then I get a list with no duplicates but if I add 'count(*) as total' the total includes duplicates so is incorrect.

How can I get round this?

Viewing all articles
Browse latest Browse all 13329

Trending Articles