0% found this document useful (0 votes)
4 views2 pages

Lab1 CSI104

The document provides details about a student named Đào Thanh Toàn, including their ID and date of birth. It also includes two tables: one for students with sample data and another for departments, along with SQL statements for various tasks such as selecting, counting, and updating student records. The SQL statements contain errors and inconsistencies that need correction for proper execution.

Uploaded by

daothanhtoan0910
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Lab1 CSI104

The document provides details about a student named Đào Thanh Toàn, including their ID and date of birth. It also includes two tables: one for students with sample data and another for departments, along with SQL statements for various tasks such as selecting, counting, and updating student records. The SQL statements contain errors and inconsistencies that need correction for proper execution.

Uploaded by

daothanhtoan0910
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

StudentID:HE181420 StudentName: Đào Thanh Toàn

DateOfBirth 9/10/2004

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 NumberOfStude Place


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

Write SQL statements to perform the following tasks.

1. Select the name and gender of all female students

SELECT female FROM Gender;

2. Calculate the average GPA of all male students

SELECT AVG(Price) FROM GPA;

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

4. SELECT name and age FROM col2 , col3WHERE student=’Table1’ AND years old
>'21';
5. Select the name and gender of all students whose name starts with 'J'

SELECT name and gender FROM name ,gender

WHERE Name LIKE 'J%';

6. Select the student with the highest GPA

SELECT DISTINCT highest FROM GPA;

7. Count the number of students of all departments.

8. Count the number of female students

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

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

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

12. Select top 5 students of the AI department with the highest GPA,
ordered by the student's GPA in descending order.

13. Select the list of female students of the SE department and sort them
in descending order of GPA.

14. 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’

DELETE FROM Customer WHERE CustomerName='S9393';

You might also like