Download OrderEntryQ41

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
[QueryID:41]
Using two Type I nested queries, list the product number, the name, and the price of
products with a price greater than $150 that were ordered on January 23, 2004.
The following steps may be helpful in formulating the query for the
problem:
1. Mapping the data items required to the column names in the DB for the host/main
query
Product number  ProdNo
Product name  CustLastName, CustFirstName
Price of products  ProdPrice
2. Interpret the row selection condition for the host/main query
 Each product has a price greater than $150  ProdPrice > 150
 Products were ordered on January 23 2004  ProdNo IN the group of
products that were ordered on January 23 2004
Note: the list of products that were ordered on January 23 2004 can be obtained by
a subquery
First subquery:
i). Mapping the data items required to the column names in the DB for the
subquery query
Product number  ProdNo
ii). Interpret the row selection condition for the subquery
 Product was ordered on January 23 2004  OrdNo IN the group of
orders that were placed on
January 23 2004
Note: the list of orders that were ordered on January 23 2004 can be
obtained by another subquery
Second subquery:
a) Mapping the data items required to the column names in the DB for
the subquery query
Order number  OrdNo
b) Interpret the row selection condition for the second subquery
 orders placed on January 23 2004  OrdDate = ‘23-Jan-2004’
c) Identify the table for the second subquery query
orderTbl table
d) Group result or individual result
©H.Y Lu 2008
1
No aggregate function is used  individual result, so Group By is not
needed
e) Using the template:
SELECT <list of columns or expressions >
FROM <list of tables or join operations>
WHERE <row selection condition >
iii). Identify the table for the first subquery query
ordLine table
iv. Group result or individual result
No aggregate function is used  individual result, so Group By is not needed
v. Using the template:
SELECT <list of columns or expressions >
FROM <list of tables or join operations>
WHERE <row selection condition including a subquery >
3. Identify the table(s) needed for the host/main qiery
product table
4. Group result or individual result
No aggregate function is used  individual result, so Group By is not needed
5. Using the template:
SELECT <list of columns or expressions >
FROM <list of tables or join operations>
WHERE <row selection condition including a subquery>
©H.Y Lu 2008
2