[ACCEPTED]-SQL distinct and count-distinct
Accepted answer
SELECT date, PhoneNumber, count(phone) AS count
FROM calls
GROUP BY date, PhoneNumber
should do it I think
0
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.)
0
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.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.