[ACCEPTED]-SQL distinct and count-distinct
SELECT date, PhoneNumber, count(phone) AS count FROM calls GROUP BY date, PhoneNumber
should do it I think
You may want to try something like
SELECT Date, Phone, Count(*) As Count From Calls GROUP BY Date, Phone
This will 3 give you a tally of each phone number on 2 each date, with how many times that number 1 appeared on that date.
SELECT date, phone, count(phone) AS count FROM calls GROUP BY date, phone
(You don't need DISTINCT with a GROUP BY.)
That's because you're grouping by date not by 3 phone.
In one grouping of a date there may be 2 three different numbers and it's impossible 1 for SQL to know which one you want.
Try the Following
Count(phone) FROM calls
Will 1 give you the Distinct Count.
More Related questions