How do put this into one query?
For example:
SELECT * FROM `result` WHERE status = 'new' AND YEAR(`end_date`) = '2012' limit 20
SELECT * FROM `result` WHERE status = 'new' AND YEAR(`end_date`) = '2013' limit 20
SELECT * FROM `result` WHERE status = 'new' AND YEAR(`end_date`) = '2014' limit 20
SELECT * FROM `result` WHERE status = 'new' AND YEAR(`end_date`) = '2015' limit 20
SELECT * FROM `result` WHERE status = 'new' AND DAY(`end_date`) = '1' limit 20
SELECT * FROM `result` WHERE status = 'new' AND DAY(`end_date`) = '2' limit 20
... and to 31
and same for the Month Jan to Dec
Basically show 20 records of each day, month and year.
unions.row_number(). This makes it extremely hard to get20 records per groupinstead ofjust 20 records. This means that writing each query independantly (and possibly usingUNIONto combine the results) really is the most straight forward option.