Question: For each of the subquery types in Chapter 7, write a similar query on the sakila database. Include the English query, the SQL query, and

For each of the subquery types in Chapter 7, write a similar query on the sakila database. Include the English query, the SQL query, and the result set.

  1. Subquery using an aggregate function (AVG, SUM, MIN, MAX, COUNT) (see fig 7-1 p 201)
  2. Subquery using IN phrase (fig 7-3 p 205)
  3. Subquery with a comparison operator (fig 7-4, p 207)
  4. Subquery using ALL (7-5, p 209)
  5. Subquery using ANY (7-6, p 211)
  6. Subquery using EXISTS (7-8, p 215)
  7. Subquery in SELECT clause (7-9, p 217)
  8. Subquery in FROM clause (7-10, p 219)
  9. Complex query with multiple subqueries (7-11, p 221)

For each of the subquery types in Chapter 7, write a similar

Subquery in WHERE using Aggregate Function SELECT invoice number, invoice date, invoice total FROM invoices WHERE invoice total > (SELECT AVG (invoice total) FROM invoices) ORDER BY invoice total The value returned by the subquery 1879.741316 The result set Invoice number 989319-487 97/522 989319-417 989319-427 989319-477 587056 invoice_date 2018-06-20 2018-06-28 2018-07-23 2018-06-16 2018-06-08 2018-06-30 invoice total 1927.54 1962. 13 2051.59 2115.81 2184.11 2184.50 (21 rows) Subquery in WHERE using Aggregate Function SELECT invoice number, invoice date, invoice total FROM invoices WHERE invoice total > (SELECT AVG (invoice total) FROM invoices) ORDER BY invoice total The value returned by the subquery 1879.741316 The result set Invoice number 989319-487 97/522 989319-417 989319-427 989319-477 587056 invoice_date 2018-06-20 2018-06-28 2018-07-23 2018-06-16 2018-06-08 2018-06-30 invoice total 1927.54 1962. 13 2051.59 2115.81 2184.11 2184.50 (21 rows)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!