Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You should write queries to answer the following questions. Use ' AS ' to change the column name where appropriate. Unless otherwise specified, you should

You should write queries to answer the following questions.
Use 'AS' to change the column name where appropriate.
Unless otherwise specified, you should use SUB-QUERIES and the quantifiers SOME, ANY, ALL, IN and NOT IN to answer the questions. Note that SQLite does not support SOME, ANY, ALL so you should use the equivalent min/max aggregate functions in the SUB-QUERIES.. You should also write each clause on a separate line.
select staffNo, salary
from Staff
where salary >
(select avg(salary)
from Staff
group by branchNo);
It is recommended that you develop the answer to the question in SQLite outside of Canvas. Add each query to a file one at a time (as the previous one is determined to be correct), for example, printing_query_ts4.1.sql.
In SQLite you can use the command .read to execute the SQL commands contained in a file, e.g.
sqlite>.read printing_query_ts4.1.sql
if you turn on command echo it will also output the sql to make it easier for a tutor to help you
sqlite>.echo ON
Tasks
Task 4.1
List the names and phone numbers of all customers who have a rush job (jobtype =R)
Task 4.2.
List all items with a price below the average price of an item.
Task 4.3.
Find the earliest po_date for each vendor_id in the pos table, include all the columns from the pos table and order by vendor_id. This cannot be done by a GROUP BY. You will need to use a correlated query based on the vendor_id.
Task 4.4.
Find the po_items with quantity exceeding any (i.e. at least one) quantity for job_id 002. Exclude job 002 from the final output.
Task 4.5.
Find all purchase orders (POS) for publishers with a credit code of C. Remember KNOW THY SCHEMA: pos does not directly connected to publishers. Use SUB-QUERIES and the IN operator.
Task 4.6.
Find all publishers which have NOT had any bookjobs with pos from vendor_id 'ABC'. Your answer needs to include publishers who have not had any bookjobs at all as well. Use NOT IN and IN.
HINT: which publishers have had POS with the vendor with vendor_id 'ABC'?
Task 4.7.
Find all those po_items with an item that has a price exceeding 50.00 and associated with one or more pos from vendor_id ABC. Use the IN clause.

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

Database And Expert Systems Applications 23rd International Conference Dexa 2012 Vienna Austria September 2012 Proceedings Part 1 Lncs 7446

Authors: Stephen W. Liddle ,Klaus-Dieter Schewe ,A Min Tjoa ,Xiaofang Zhou

2012th Edition

3642325998, 978-3642325991

More Books

Students also viewed these Databases questions

Question

Name each acid. a. HF(aq) b. HNO3(aq) c. H2C2O4(aq)

Answered: 1 week ago