Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

intro to database part 3. (TCO 7) Given the books table described below, which o

ID: 3823271 • Letter: I

Question

intro to database

part 3. (TCO 7) Given the books table described below, which of the following will display the date of the book with the earliest publication date?
books:   bookid(PK), ISBN, title, pubdate, cost, retail, category, pubid(FK) (Points : 3)        SELECT MIN(pubdate) FROM books;
       SELECT title FROM books WHERE pubdate = MIN(pubdate);
       SELECT title FROM books WHERE pubdate < MIN(pubdate);
       SELECT pubdate from books WHERE MIN(pubdate) IS NOT NULL;

       When we need to sum up values
       When we need to convert string data into date or number values
       When we need to select rows from a table with a condition that depends on the data from a different table
       No way to tell without an ERD

part. 4. (TCO 7) Given the books table described below, which of the following will list retail price of the most expensive book in the COMPUTER category?
books:   bookid(PK), ISBN, title, pubdate, cost, retail, category, pubid(FK) (Points : 3)        SELECT MAX(retail) FROM books GROUP BY category;
       SELECT MAX(retail) FROM books WHERE category = ‘COMPUTER’;
       SELECT MAX(retail) FROM books HAVING category = ‘COMPUTER’;
       SELECT retail FROM (SELECT MAX(retail) FROM books);

Explanation / Answer

part3 ans.
   SELECT pubdate from books WHERE MIN(pubdate) IS NOT NULL;

part 4 ans.
   SELECT MAX(retail) FROM books WHERE category = ‘COMPUTER’;

part . 5. (TCO 7) Which of the values listed below can be returned by a subquery referenced as follows?
WHERE vendorid = (subquery) (Points : 3)
  
ANS . single value

part. 6. (TCO 7) What type of subquery is executed only once for the entire query?

ANS .Correlated

part 7. (TCO 7) Given the two tables described below, which of the following queries will display the names of the customers whose orders have shipped?

ANS. SELECT lastname, firstname FROM customer WHERE customerid = (SELECT customerID FROM order WHERE shipdate = orderdate);

Part 8. (TCO 7) Given the two tables described below, which of the following queries will display each customerid along with the number of orders placed by that customer?

ANS.SELECT customerid, COUNT(orderid) FROM order GROUP BY customerid;

part. 9. (TCO 7) Given the books table described below, which of the following will display each category along with the average retail price of books in that category?

ANS. SELECT category, AVG(retail) FROM books GROUP BY category:

Part. 10. (TCO 7) Which of these scenarios would justify the usage of a subquery?

ANS.When we need to select rows from a table with a condition that depends on the data from a different table