Create the following tables in sql:
1. Courses
Cno. Course_name
202 Accountancy
301 Statistics
111 Marketing
102 Mathematics
222 IT
2. Students
Sno. first_name last_name DOB Gender Grade Cno.
1 Rachel Green 30/11/2003 F A 202
2 Monica Geller 18/11/2003 F A 102
3 Ross Geller 16/06/2002 M B 222
4 Chandler Bing 12/04/2003 M D 202
5 Joey Tribbiani 23/09/2002 M C 301
6 Pheobe Buffay 02/04/2002 F B 111
7 Ellena Gilbert 28/01/2004 F A 301
8 Stefan Salvator 15/06/2003 M D 102
9 Boney Bannet 20/08/2002 F C 222
10 Caroline Forbes 08/05/2004 F A 111
Solution
1.
Insert records in the above tables:
Solution
1.
2.
List all the information about all students from students table.
Solution
List all students names along with their DOB from students table.
Solution
List the first name of all the female students
Solutions
List the name of the students with ‘A’ grade in accountancy.
Solution
List the first name of male student studying IT
Solutions
List the names od the student studying marketing.
Solution
List the names of the students who are not born on 30/11/2003.
Solution
List the student names and grades, whose grades are between A and C.
Solution
List the students whose names start with ‘R’.
Solution
List the student names having ‘o’ as the second character.
Solution
List out the student number, first name, grades in ascending order of first name.
Solution
List the students name, grade, gender, and course no. in ascending order of course no. and
then descending order of grades.
Solution
List the details of all male students.
Solution
List the details of all students who are not male.
Solution
List the details of all male students who are having grade B.
Solution
List the number of students studying .
Solution
List the average number of female student studying.
Solution
Write a query to inner join two tables to display the first name & course name.
Solution