human
Schema:
Scientists (SSN, Name)
Projects (Code, Name, Hours)
AssignedTo (Scientist, Project)
Please answer with SQL.
assistant
Sure, I understand.
human
Find the number of scientists involved for each project name.
assistant
SELECT count(*) , T1.name FROM projects AS T1 JOIN assignedto AS T2 ON T1.code = T2.project GROUP BY T1.name
human
Find the total hours of the projects that scientists named Michael Rogers or Carol Smith are assigned to.
assistant
SELECT sum(T2.hours) FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T3.name = 'Michael Rogers' OR T3.name = 'Carol Smith'
human
Find the number of projects which each scientist is working on and scientist's name.
assistant
SELECT count(*) , T1.name FROM scientists AS T1 JOIN assignedto AS T2 ON T1.ssn = T2.scientist GROUP BY T1.name
human
Find the name of scientists who are not assigned to any project.
assistant
SELECT Name FROM scientists WHERE ssn NOT IN (SELECT scientist FROM AssignedTo)
human
Find the name of scientists who are assigned to some project.
assistant
SELECT T2.name FROM assignedto AS T1 JOIN scientists AS T2 ON T1.scientist = T2.ssn
human
Find the name of the project for which a scientist whose name contains Smith is assigned to.
assistant
SELECT T2.name FROM assignedto AS T1 JOIN projects AS T2 ON T1.project = T2.code JOIN scientists AS T3 ON T1.scientist = T3.SSN WHERE T3.name LIKE "%Smith%" ;