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 isnt 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?
matterid
clientname
visitdate
I want to get totals from this (between certain dates but that isnt 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?