Commit a9100c76 authored by michael lundquist's avatar michael lundquist
Browse files

Adding some stuff for week 6.

parent bc8aa0a6
/**
# problem1
To complete problem 1, write an SQL query that uses a single-row subquery in a WHERE clause.
*/
SELECT ORDER#, ORDERDATE FROM ORDERS WHERE CUSTOMER# = (SELECT CUSTOMER# FROM CUSTOMERS WHERE LASTNAME = 'SMITH' AND FIRSTNAME = 'JENNIFER');
/**
## problem 2
To complete problem 2, write an SQL query that uses a multiple-column subquery in a FROM clause. The subquery will use the GROUP BY statement.
*/
SELECT * FROM PUBLISHER WHERE PUBID IN (SELECT * FROM (SELECT PUBID FROM BOOKS GROUP BY PUBID ORDER BY AVG(COST) DESC) WHERE ROWNUM < 3);
-- Shows information for publishers whose average book price is in the 2 most expensive averages.
/**
## problem 3
To complete problem 3, write an SQL query that uses a single-row subquery in a WHERE clause.
*/
SELECT TITLE, COST FROM BOOKS B WHERE COST BETWEEN (SELECT MINRETAIL FROM PROMOTION WHERE GIFT='BOOK LABELS') AND (SELECT MAXRETAIL FROM PROMOTION WHERE GIFT='BOOK LABELS');
--Shows all the books that receive a book label and the cost of the book.
/**
## problem 4
To complete problem 4, write an SQL query that joins two tables and uses a multiple-row subquery in a HAVING clause. The subquery will join two tables.
*/
SELECT ISBN FROM BOOKS JOIN ORDERITEMS USING (ISBN) GROUP BY ISBN HAVING MOD(SUM(ISBN), 10) IN (SELECT * FROM (SELECT MOD(TO_NUMBER(TO_CHAR(PUBDATE, 'SSSSS')),10) FROM BOOKS JOIN BOOKAUTHOR USING (ISBN) JOIN AUTHOR USING (AUTHORID)) WHERE ROWNUM < 5);
--SEMI RANDOM NUMBER GENERATOR USING THE PUB DATE AND THE ISBN TO RANDOMLY GET BOOKS.
-- possible joins:
-- customer -- orders
-- orders -- order items -- books
-- publisher - books
-- books -- bookauthor -- author
/**
## problem 5
To complete problem 5, write an SQL query that uses a multiple-row subquery in a WHERE clause. The subquery will include the GROUP BY statement and another multiple-row subquery in a HAVING clause.
*/
/**
## problem 6
To complete problem 6, write an SQL query that uses two multiple-row subqueries in a WHERE clause joined with the AND operator. Each subquery will join multiple tables.
*/
/**
## problem 7
To complete problem 7, write an SQL query that uses a single-row subquery in a WHERE clause.
*/
/**
## problem 8
To complete problem 8, write an SQL query that joins four tables and uses a single-row subquery in a WHERE clause.
*/
/**
## problem 9
To complete problem 9, write an SQL query that joins two tables and uses a multiple-row subquery in a WHERE clause. The subquery will join three tables.
*/
/**
## Problem 10
To complete problem 10, write an SQL query that uses a single-row subquery in a WHERE clause.
*/
\ No newline at end of file
/**
# problem1
To complete problem 1, write an SQL query that uses a single-row subquery in a WHERE clause.
*/
/**
## problem 2
To complete problem 2, write an SQL query that uses a multiple-column subquery in a FROM clause. The subquery will use the GROUP BY statement.
*/
/**
## problem 3
To complete problem 3, write an SQL query that uses a single-row subquery in a WHERE clause.
*/
/**
## problem 4
To complete problem 4, write an SQL query that joins two tables and uses a multiple-row subquery in a HAVING clause. The subquery will join two tables.
*/
/**
## problem 5
To complete problem 5, write an SQL query that uses a multiple-row subquery in a WHERE clause. The subquery will include the GROUP BY statement and another multiple-row subquery in a HAVING clause.
*/
/**
## problem 6
To complete problem 6, write an SQL query that uses two multiple-row subqueries in a WHERE clause joined with the AND operator. Each subquery will join multiple tables.
*/
/**
## problem 7
To complete problem 7, write an SQL query that uses a single-row subquery in a WHERE clause.
*/
/**
## problem 8
To complete problem 8, write an SQL query that joins four tables and uses a single-row subquery in a WHERE clause.
*/
/**
## problem 9
To complete problem 9, write an SQL query that joins two tables and uses a multiple-row subquery in a WHERE clause. The subquery will join three tables.
*/
/**
## Problem 10
To complete problem 10, write an SQL query that uses a single-row subquery in a WHERE clause.
do hands-on assignments 1-5 and 9
*/
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment