SELECT text, count(*) as 'A'
FROM all_queries
WHERE dates > LAST_DAY(CURDATE()) + INTERVAL 1 DAY - INTERVAL 1 MONTH
AND dates < DATE_ADD(LAST_DAY(CURDATE()), INTERVAL 1 DAY)
group by text
HAVING text in ('Привет','Хэллоу','Здравствуйте')
ORDER BY A desc
$words = array('Привет', 'привет', 'Хай', 'хай', 'Хэй', 'Хэллоу');
$impl = implode('%', $words);
$where = "TEXT LIKE '%{$impl}%'";