[ACCEPTED]-SQL distinct and count-distinct

Accepted answer
Score: 32
SELECT date, PhoneNumber, count(phone) AS count
    FROM calls
    GROUP BY date, PhoneNumber 

should do it I think


Score: 8

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.

Score: 4
SELECT date, phone, count(phone) AS count FROM calls GROUP BY date, phone

(You don't need DISTINCT with a GROUP BY.)


Score: 2

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.

Score: 0

Try the Following

Count(phone) FROM calls

Will 1 give you the Distinct Count.

More Related questions