MySQL Multiple counts from same columns?

J L

New member
Looking for some assistance on a MySQL query to select multiple possibilities from the same columns in the same table. For example:

Table: DATA

NAME DATE
A 20100325
B 20100325
B 20100324
C 20100324
D 20100324
A 20100314
B 20100314
E 20100314
F 20100101

Basically, I want 1 row with the count of distinct NAMEs which have more than 1 instances within 3 days of today, the count of distinct NAMEs where there is 1 or more instances within 3 days of today, and the count of distinct NAMEs within the last 30 days. The counts are not mutually exclusive so from the table above, I want:

1 4 5

The 1 is just B, the 4 is A,B,C,D and the 5 is A,B,C,D,E. Make sense?
 
Back
Top