Unit 3 SQL Prac Notes Ex1
Unit 3 SQL Prac Notes Ex1
..................... Queries.......................................
O/P=
NAME
--------------------------------------------------
Rahul
O/P=
COURSENAME CREDITS
-------------------------------------------------- ----------
Mathematics 4
Science 3
History 3
English 4
Geography 3
3) Display the names and ages of students who are older than 20 years.
SQL> select name, age from students where age > 20;
O/P=
NAME AGE
-------------------------------------------------- ----------
Priya 22
Alok 21
Suresh 23
O/P=
COURSEID COUNT(STUDENTID)
---------- ----------------
102 1
101 1
104 1
105 1
103 1
O/P=
total credits
-------------
17
7) Display the student names and the courses they are enrolled in.
SQL> select students.name, courses.coursename
from students, courses, enrollments
where students.studentid = enrollments.studentid and
enrollments.courseid = courses.courseid;
O/P=
NAME COURSENAME
--------------------------------------------------
--------------------------------------------------
Rahul Mathematics
Priya Science
Alok History
Neha English
Suresh Geography
9) List the courses alongwith the number of students enrolled in each course.
10) Show the student names, course names and cities of all students
alongwith course names they are enrolled in.
***** * *****