wisseman78 wisseman78 - 4 months ago 7
SQL Question

Specific Column is not showing up, when it should?

I don't know what's going on with my code here. I am trying to return the highest number of calls received by particular phone numbers, and find the top 7 numbers by calls received, but I am only getting the count column in my results. The code is:

SELECT COUNT (call_id) FROM call_test
GROUP BY receiver_id
ORDER BY COUNT(call_id) DESC
LIMIT 7;


But all it is returning is:

COUNT(call_id)
3
2
2
2
2
1
1


I think my code is right, but how do you show the particular numbers that correspond to the respective counts? This is SQLPro for MAC.

Answer

Is it as simple as including the number in the select?

SELECT receiver_id, COUNT(call_id)
FROM call_test
GROUP BY receiver_id
ORDER BY COUNT(call_id) DESC
LIMIT 7;