COMP3311 Final Exam 21T3 The University of New South Wales
COMP3311 Database Systems
Final Exam 21T3
Database Systems
[Front Page] [Notes] [Database] [Course Website] [Cheat Sheets]
[Q1] [Q2] [Q3] [Q4] [Q5] [Q6] [Q7] [Q8] [Q9] [Q10]

Question 2 (5 marks)

Write an SQL view that gives a list of how many unsold properties of each type are in each suburb.

Define the view as q2(suburb,ptype,nprops), where the attributes are:

The output should be ordered by property type, and then by suburb. What the output should look like:

property=# select * from q2;
     suburb     |   ptype   | nprops 
----------------+-----------+--------
 Alexandria     | Apartment |     42
 Bondi Junction | Apartment |     41
 Coogee         | Apartment |     47
 Kingsford      | Apartment |     43
 Alexandria     | House     |     34
 Bondi Junction | House     |     38
 Coogee         | House     |     38
 Kingsford      | House     |     36
 Alexandria     | Townhouse |      9
 Bondi Junction | Townhouse |      9
 Coogee         | Townhouse |      6
 Kingsford      | Townhouse |      9
(12 rows)

Instructions:

End of Question