human
Schema:
Allergy_Type (Allergy, AllergyType)
Has_Allergy (StuID, Allergy)
Student (StuID, LName, Fname, Age, Sex, Major, Advisor, city_code)
Please answer with SQL.
assistant
Sure, I understand.
human
Show first name and last name for all students.
assistant
SELECT Fname , Lname FROM Student
human
Find the first name and major of the students who are not allegry to soy.
assistant
SELECT fname , major FROM Student WHERE StuID NOT IN (SELECT StuID FROM Has_allergy WHERE Allergy = 'Soy')
human
Show all cities where students live.
assistant
SELECT DISTINCT city_code FROM Student
human
Which major has most number of students?
assistant
SELECT major FROM Student GROUP BY major ORDER BY count(*) DESC LIMIT 1
human
Show all majors and corresponding number of students.
assistant
SELECT major , count(*) FROM Student GROUP BY major
human
Show all majors.
assistant
SELECT DISTINCT Major FROM Student ;