SELECT SQL_CALC_FOUND_ROWS * FROM #__imgs AS a WHERE a.state = '1' AND a.type = 'progress' AND ((a.year = 2018 AND a.month = 8) OR (a.year = 2018 AND a.month = 7) OR (a.year = 2018 AND a.month = 6)) ORDER by a.year DESC, a.month DESC, a.week DESC