Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

just need help with some SQL homework here is the SQL tables: Find the registration numbers of all trucks. The results should be displayed in

just need help with some SQL homework

here is the SQL tables:

image text in transcribed

  1. Find the registration numbers of all trucks. The results should be displayed in the ascending order of the statuses and for all trucks that have the same status, the results should be displayed in the descending order of registration numbers.
  2. Find the total number of distinct names of cities being the departure locations for at least one trip. A city is a departure location when it is a departure location of the first leg of a trip.
  3. Find the total number of trips performed by each driver. List the driving licence numbers associated with the total number of trips. Ignore the drivers who performed no trips so far.
  4. Find the total number of times each truck has been used for the trips. List the truck registration numbers associated with the total number of trips. List only the trucks used more than 5 times.
  5. Find the trip numbers, driving licence numbers of the drivers who performed the trips and the registration numbers of the trucks used for the trips done in the first 30 days after 1 February 2016.
  6. Find the total number of trips that started or finished or passed through a city that has a letter y in its name.
CREATE TABLE EMPLOYEE ( ( ENUM DECIMAL (12) NOT NULL, FNAME VARCHAR(50) NOT NULL, INITIALS VARCHAR(5) NULL, LNAME VARCHAR(50) NOT NULL, ' DOB DATE A. NULL, ' BLDG DECIMAL (3) NOT NULL, STREET VARCHAR(50) NOT NULL, ' SUBURB VARCHAR(50) NOT NULL, STATE VARCHAR(5) NOT NULL, ZIPCODE DECIMAL (4) NOT NULL, CONSTRAINT EMPLOYEE_PKEY PRIMARY KEY (ENUM)); /* RRRRRR */ CREATE TABLE DRIVER ENUM DECIMAL (12) NOT NULL, LNUM DECIMAL (8) NOT NULL, STATUS VARCHAR(10) NOT NULL, CONSTRAINT DRIVER_PKEY PRIMARY KEY (ENUM), CONSTRAINT DRIVER_UNIQUE UNIQUE (LNUM), CONSTRAINT DRIVER_FKEY FOREIGN KEY (ENUM) REFERENCES EMPLOYEE (ENUM), CONSTRAINT DRIVER_STATUS CHECK ( STATUS IN ('AVAILABLE', 'BUSY', 'ON LEAVE')); / */ CREATE TABLE ADMIN ENUM DECIMAL (12) NOT NULL, POSITION VARCHAR(50) NOT NULL, CONSTRAINT ADMIN_PKEY PRIMARY KEY (ENUM), CONSTRAINT ADMIN_FKEY FOREIGN KEY(ENUM) REFERENCES EMPLOYEE (ENUM)); /* - WWW */ CREATE TABLE TRUCK REGNUM VARCHAR(10) NOT NULL, DET CAPACITY DECIMAL (7) NOT NULL, WEIGHT DECIMAL (7) NOT NULL, STATUS VARCHAR(10) NOT NULL, CONSTRAINT TRUCK_PKEY PRIMARY KEY (REGNUM), CONSTRAINT TRUCK STATUS CHECK ( STATUS IN ('AVAILABLE', 'USED', 'MAINTAINED')), CONSTRAINT TRUCK_WEIGHT CHECK ( WEIGHT > 0.0 AND WEIGHT 0.0 AND CAPACITY

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions