Exercises Query SQL
Exercises Query SQL
Data Base
Bachelor in Data Science and Engineering
SUBJECT: 2 Exercises (Topic 2.2: Queries. SQL)
The meaning of these relations is straightforward; for example, enrolled has one
record per student-class pair such that the student is enrolled in the class.
Write the following queries in SQL.
a. Select the Level and the average age of students for that Level, for each Level.
b. Select the Level and the average age of students for that Level, for all Levels
except JR.
c. Select the names of students who are not enrolled in any class.
CRIMINAL.Type={common, noncommon}
RECORD.Status ={open, close}
1
Write the following queries in SQL.
a. Select criminals (code and number) from open records of non-common
criminals.
b. Select for each police station: district and the number of police officers
ordered by the name.
c. Select for each criminal: code, name, alias, type and the number of records
associated.
2
belong to more than one group. Each group is identified by a name that
describes the group.
• Finally, the database keeps the information about customers. For each
customer, the database stores that person’s unique name, address, the total
amount of dollars spent in the gallery and the artists and groups of art that the
customer tends to like.
A possible solution is: