SQL Assignment
Due: September 11, 2009
Using the MySQL SQL interface, answer the following queries.
Put your name in the file within a comment.
For each query, include a comment that states the query.
All columns must have reasonable names.
- Find the userid, shares, price and amount spent for all transactions totalling over $100,000.
- For all purchases in March, 2003, find the userid, the cost, and the commission (1% of the cost)
- For all purchases in March, 2003, find the userid, the cost, and the commission, where the commission is 1% for purchases of 500 or more shares, and 2% otherwise
- Output all the states with more than 10 customers
- Find the lowest low and the highest high price in stockprices.
- Find the average cost of purchases in March, 2003
- Find the total number of shares bought by customers in 2003
- For each year, find the total change in stock holdings for each customer, assuming the customer has more than 1 transaction. Output the userid as well as the year.
Write a JDBC program to answer the last query. You may only send one
query to the database, and it is:
select * from stockorders;
Make sure your answer is the same as with the database query.