SELECT IFNULL(SUM(DATEDIFF(CURDATE(), repaints.release) < 31 AND DATEDIFF(CURDATE(), repaints.release) > -1 AND NOW() > repaints.release), 0) + IFNULL(SUM(DATEDIFF(CURDATE(), news.release) < 31), 0) AS freshcnt, SUM(repaints.published = 9) AS uffreshcnt, SUM(repaints.published = 0) AS ufreshcnt, SUM(repaints.published = 1 AND NOW() < repaints.release) AS pfreshcnt, aircraft.dev, aircraft.id, aircraft.title, SUM(((repaints.published = 1) AND NOW( ) >= repaints.release AND repaints.release != '0000-00-00 00:00:00')) AS noaccessneeded, SUM(( repaints.p3d = '1') AND repaints.published = 1 AND NOW( ) >= repaints.release AND repaints.release != '0000-00-00 00:00:00') AS noaccessneeded_simselect FROM repaints LEFT JOIN aircraft ON repaints.aircraft = aircraft.id LEFT JOIN news ON repaints.id = news.itemid GROUP BY aircraft.id ORDER BY aircraft.dev, aircraft.id EDRM-Repaints – Downloads