[DATABASE]SQL query examples

There are three relations used for this example – RENTAL_CUSTOMER, CAR, RENTAL.
Below are the SQL statements used to create the relations.
Screenshot 2018-11-30 at 10.55.29 PM
Screenshot 2018-11-30 at 11.02.36 PM.png
Screenshot 2018-11-30 at 11.13.20 PM.png

Data have been inserted to the relations:
RENTAL_CUSTOMER
Screenshot 2018-11-30 at 11.20.54 PM

CAR
Screenshot 2018-11-30 at 11.22.21 PM.png

RENTAL
Screenshot 2018-11-30 at 11.22.57 PM

List all cars rented by Smith since 1st of August 2017
Screenshot 2018-11-30 at 11.30.30 PM

List each make of the cars and the total number of cars rented of that make
Screenshot 2018-11-30 at 11.37.51 PM

A new car is bought and is updated to CAR, List the each make of the car and the number of that make
The new record of CAR:
Screenshot 2018-11-30 at 11.42.08 PM

Now count the number of cars of each make:
Screenshot 2018-11-30 at 11.43.25 PM

List the registration number and the make of the cars that have not been rented
Screenshot 2018-11-30 at 11.55.04 PM

Update Jones phone number to 988-2223
Before change:
Screenshot 2018-12-01 at 12.01.45 AM.png

The change statement:

Screenshot 2018-12-01 at 12.03.17 AM
after the change:
Screenshot 2018-12-01 at 12.04.25 AM

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s