You are on page 1of 2

E4.1 Write a query to display all Theme Parks except those in the UK.

 SELECT * FROM THEMEPARK WHERE PARK_COUNTRY != 'UK';


E4.2 Write a query to display all the sales that occurred on the 18th May 2007.
 SELECT * FROM SALES WHERE SALE_DATE = '2007-05-18';
E4.3 Write a query to display the ticket prices between €20 AND €30.
 SELECT * FROM TICKET WHERE TICKET_PRICE BETWEEN 20 AND 30;
E4.4 Display all attractions that have a capacity of more than 60 at the Theme Park
FR1001.
 SELECT * FROM ATTRACTION WHERE ATTRACT_CAPACITY > 60 AND PARK_CODE =
'FR1001';
E4.5 Write a query to display the hourly rate for each attraction where an employee

m
er as
had worked, along with the hourly rate increased by 20%. Your query should only display the

co
eH w
ATTRACT_NO, HOUR_RATE and the HOUR_RATE with the 20% increase.

o.
 SELECT DISTINCT A.ATTRACT_NO, H.HOUR_RATE, (H.HOUR_RATE * 120 / 100) AS
rs e
ou urc
HOUR_RATE_INCREASED_BY_20 FROM ATTRACTION AS A INNER JOIN HOURS AS H
ON A.ATTRACT_NO = H.ATTRACT_NO;
o

E5.1 Write a query to display all unique employees that exist in the HOURS table;
aC s

 SELECT DISTINCT E.* FROM EMPLOYEE AS E INNER JOIN HOURS AS H ON


v i y re

H.EMP_NUM = E.EMP_NUM;
E5.2 Display the employee numbers of all employees and the total number of hours they
ed d

have worked.
ar stu

 SELECT E.EMP_NUM, SUM(H.HOUR_RATE) FROM EMPLOYEE AS E INNER JOIN HOURS


AS H ON H.EMP_NUM = E.EMP_NUM GROUP BY E.EMP_NUM; // Error
sh is

E5.3. Show the attraction number and the minimum and maximum hourly rate for each
Th

attraction.
 SELECT A.ATTRACT_NO, MIN(H.HOUR_RATE), MAX(H.HOUR_RATE) FROM
ATTRACTION AS A INNER JOIN HOURS AS H ON A.ATTRACT_NO = H.ATTRACT_NO
GROUP BY A.ATTRACT_NO; // Error
E5.4 Write a query to show the transaction numbers and line prices (in the SALES_LINE
table) that are greater than €50.
 SELECT TRANSACTION_NO, LINE_PRICE FROM SALES_LINE WHERE LINE_PRICE > 50;
E5.5 Display all information from the SALES table in descending order of the sale date

This study source was downloaded by 100000820852645 from CourseHero.com on 11-16-2021 10:55:16 GMT -06:00

https://www.coursehero.com/file/78944140/dbdocx/
 SELECT * FROM SALES ORDER BY SALE_DATE DESC;

E6.1 Use the cross join to display all rows in the EMPLOYEE and HOURS tables. How
many rows were returned?
 SELECT * FROM EMPLOYEE CROSS JOIN HOURS; /* The number of results is the
number of rows from EMPLOYEE multiplies by the number of rows from HOURS =
77*/
E6.2 Write a query to display the attraction number, employee first and last names and
the date they worked on the attraction. Order the results by the date worked.
 SELECT H.ATTRACT_NO, E.EMP_FNAME, E.EMP_LNAME, H.DATE_WORKED FROM
EMPLOYEE AS E INNER JOIN HOURS AS H ON E.EMP_NUM = H.EMP_NUM ORDER BY

m
er as
H.DATE_WORKED;

co
eH w
E6.3 Display the park names and total sales for Theme Parks who are located in the

o.
country ‘UK’ or ‘FR’. rs e
ou urc
 SELECT TP.PARK_NAME, SUM(SL.LINE_PRICE) FROM THEMEPARK AS TP INNER JOIN
SALES AS S ON S.PARK_CODE = TP.PARK_CODE INNER JOIN SALES_LINE AS SL ON
o

S.TRANSACTION_NO = SL.TRANSACTION_NO WHERE TP.PARK_COUNTRY = 'UK' OR


aC s

TP.PARK_COUNTRY = 'FR' GROUP BY TP.PARK_NAME;


v i y re

E6.4 Write a query to display the names of attractions that currently have not had any
employees working on them.
ed d

 SELECT A.ATTRACT_NAME FROM ATTRACTION AS A LEFT OUTER JOIN HOURS AS H


ar stu

ON A.ATTRACT_NO = H.ATTRACT_NO WHERE H.EMP_NUM IS NULL;


E6.5 List the sale date, line quantity and line price of all transactions on the 18th May
sh is

2007. (Hint: Remember the format of MySQL dates is ‘2007-05-18’).


Th

 SELECT S.SALE_DATE, SL.LINE_QTY, SL.LINE_PRICE FROM SALES AS S INNER JOIN


SALES_LINE AS SL ON S.TRANSACTION_NO = SL.TRANSACTION_NO WHERE
S.SALE_DATE = '2007-05-18';

This study source was downloaded by 100000820852645 from CourseHero.com on 11-16-2021 10:55:16 GMT -06:00

https://www.coursehero.com/file/78944140/dbdocx/
Powered by TCPDF (www.tcpdf.org)

You might also like