5. get the list of all projects containing the ‘a’ letter in the middle of the name, and show the tasks count near each project. Mention that there can exist projects without tasks and tasks with project_id=NULL
SELECTprojects.name, count(*)
FROM tasks, projects
WHEREprojects.id=tasks.project_idANDprojects.namelike"%a%"GROUP BYprojects.nameORDER BYprojects.name;
6. get the list of tasks with duplicate names. Order alphabetically
SELECT name FROM tasks
GROUP BY name
HAVINGcount(*) >1;
7. get the list of tasks having several exact matches of both name and status, from the project ‘Garage’. Order by matches count
SELECTtasks.nameFROM tasks, projects
WHEREprojects.id=tasks.project_idANDprojects.name="Garage"GROUP BYtasks.name, status
HAVINGcount(*) >1;
8. get the list of project names having more than 10 tasks in status ‘completed’. Order by project_id
SELECTprojects.nameFROM projects, tasks
WHEREprojects.id=tasks.project_idAND status = true
GROUP BY status
HAVINGcount(*) >10;