Q:

MySQL Query Grouped Conditional Count

Here is the mySQL table data:
╔════╦══════╦══════════╦══════════════╗
║ ID ║ USER ║   DATE   ║ NUMDOWNLOADS ║
╠════╬══════╬══════════╬══════════════╣
║  1 ║ John ║ xx-xx-xx ║      1       ║
║  2 ║ Mary ║ xx-xx-xx ║      3       ║
║  3 ║ John ║ xx-xx-xx ║      5       ║
║  4 ║ Mary ║ xx-xx-xx ║      2       ║
║  5 ║ Mary ║ xx-xx-xx ║      6       ║
║  6 ║ John ║ xx-xx-xx ║      7       ║
║  7 ║ John ║ xx-xx-xx ║      1       ║
║  8 ║ Mary ║ xx-xx-xx ║      8       ║
║  9 ║ Mary ║ xx-xx-xx ║      9       ║
╚════╩══════╩══════════╩══════════════╝

What I want to accomplish is to group the data by USER, and display the total NUMDOWNLOADS per USER where NUMDOWNLOADS is > X. For example, if X=5:
John: 1 (since 1 NUMDOWNLOADS > 5, and others count collectively as 1)
Mary: 3 (since 3 NUMDOWNLOADS > 5, and others count collectively as 1)
So, (1) output per user, and (2) output total, which in this case would be 4. Clear as mud :) Ideas on statement to use?

A:

Your query is here. Try it
SELECT USER, COUNT(NUMDOWNLOADS)
FROM table_name
WHERE NUMDOWNLOADS > 5
GROUP BY USER

