And you should get a result like :SELECT state, sum(IF(month(identifier)=1,1,0)) as 'Jan', sum(IF(month(identifier)=2,1,0)) as 'Feb', sum(IF(month(identifier)=3,1,0)) as 'Mar', count(*) as TOTAL from contacts WHERE state != '' GROUP BY state;
Check this article for a step-by-step tutorial on how to use Perl to get get the values for your columns in the query without doing it manually. The article is specific for MySQL, but the algorithm works on any DBMS.+----------+-----+-----+----+-------+ | state | Jan | Feb | Mar| Total | +----------+-----+-----+----+-------+ | NY | 10 | 12 | 11 | 33 | | IL | 15 | 14 | 15 | 44 | | TX | 25 | 20 | 22 | 67 | +----------+-----+-----+----+-------+
_ _ _ _ (_|| | |(_|>< _|
In reply to Re: Selecting and ordering data over multiple date ranges
by gmax
in thread Selecting and ordering data over multiple date ranges
by peppiv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |