new sql query for categories