group by and having in sql

join shbcf.ru