0% found this document useful (0 votes)
2 views

Lab1_CSI104

The document provides a structured overview of two tables: STUDENTS and DEPARTMENTS, including sample data for each. It outlines a series of SQL tasks to manipulate and query the data, such as selecting specific student information, calculating averages, counting students, and performing updates and deletions. The tasks cover various operations like filtering by gender, age, and department, as well as sorting and aggregating data.

Uploaded by

daothanhtoan0910
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lab1_CSI104

The document provides a structured overview of two tables: STUDENTS and DEPARTMENTS, including sample data for each. It outlines a series of SQL tasks to manipulate and query the data, such as selecting specific student information, calculating averages, counting students, and performing updates and deletions. The tasks cover various operations like filtering by gender, age, and department, as well as sorting and aggregating data.

Uploaded by

daothanhtoan0910
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

StudentID: StudentName: DateOfBirth

Table 1: STUDENTS. The table has the structure and some sample data as the following.

ID Name Age Gender GPA DepID


S0019 John Smith 20 Male 8.6 SE
S0010 Jane Doe 19 Female 5.4 AI
S9393 Mark Johnson 20 Male 7.0 SE
S1012 Sara Williams 21 Female 9.0 IA
S0012 Tom Wilson 20 Male 9.0 SE

Table 2: DEPARTMENTS. The table has the structure and some sample data as the following.

ID Name NumberOfStudents Place


SE Software Engineering 50 Alpha
AI Artificial Intelligence 130 Beta
IA Information Assurance 69 Delta
BA Business Administration 230 Delta

Write SQL statements to perform the following tasks.

1. Select the name and gender of all female students

2. Calculate the average GPA of all male students

3. Select the name and age of all students who are 21 years old

4. Select the name and gender of all students whose name starts with 'J'

5. Select the student with the highest GPA

6. Count the number of students of all departments.

7. Count the number of female students

8. Calculate the total number of students in two departments SE and AI

9. Select ID, name, and gender of all students studying in the Delta building

10. Select the name and gender of all students of the SE department whose name starts with
'J'

11. Select top 5 students of the AI department with the highest GPA, ordered by the student's
GPA in descending order.
12. Select the list of female students of the SE department and sort them in descending order
of GPA.

13. Add a new student with the following information: ID: ‘S0005’, Name: ‘Alice Brown’, Age:
20, Gender: ‘Female’, GPA: 8.4, DepID: ‘SE’.

14. Update the GPA of the student with ID=’S1012’ and name=’Sara Williams’ to 9.5.

15. Delete the student with ID=‘ S9393’

You might also like