Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I was doing more SQL work and these are the questions I got stuck on table: The queries listed below must be implemented as SELECT

I was doing more SQL work and these are the questions I got stuck on

table:

image text in transcribed

The queries listed below must be implemented as SELECT statements with JOIN or OUTER JOIN operation.

  1. Find the first and the last name of the drivers who are on leave at the moment.
  2. Find the registration numbers of trucks that are used just now and that have been used for at least one trip in 2016.
  3. Find the first and the last names of drivers who performed at least one trip in January 2016. It is your task to find an appropriate standard function that can be used to extract a month and year from a date.
  4. Find the first and last names of employees who are not drivers.
  5. Find the first and last names of drivers who performed no trips so far.
  6. Find the total number of trips performed by each driver. List the driving licence numbers associated with the total number of trips. Do not ignore the drivers who performed no trips so far.
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

Modern Database Management

Authors: Heikki Topi, Jeffrey A Hoffer, Ramesh Venkataraman

13th Edition

0134773659, 978-0134773650

More Books

Students also viewed these Databases questions

Question

3. Evaluate a Web-based training site.

Answered: 1 week ago

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago