Computer Science Homework Solutions
Problem
#133950

Database Coding

1. Using the order_lines table from the database from lecture 2, write the SQL that will give the Min and Max values of the column "cost_each"

2. Using the week 2 homework database, show each customer number and count the instances of each customer_numb in the table orders.

Hint: follow this pattern (where the words TABLE and COLUMN are filling in for real names):

    SELECT COLUMN, Count(COLUMN)
    FROM TABLE
    GROUP BY COLUMN;

OR, if you'd like:

    SELECT COLUMN, Count(COLUMN) AS [COUNT OF CUSTOMER NUMBERS]
    FROM TABLE
    GROUP BY COLUMN;


3. Write the SQL to count how many authors have a last name that starts with S.

4. Find the sum of the cost line column

5. How many customers are in each state?

The "answer" is:
    SM    4
    SO    2
    ST    4
    SU    4

6. How many books on hand never ordered (the "answer" is 293)

7. Using the week 2 homework database, write the SQL that will show the average of the retail_price column in the books table

8. Write the SQL that will find the sum of the cost_line column in the table order_lines for customers who are in state "ST"

I guess we will need to do an inner join with tables customers and orders and order_lines to get the answer right?

Attached file(s):
Attachments
WEEK2_ACCESS2000.mdb  View File
Solution
What is this?
By OTA - Overall OTA Rating
Yanfang Li, PhD - 4.9/5
Purchase Cost Now
$2.19 CAD (was ~$63.84)
Included in Download
  • Plain text response
  • Attached file(s):
    • answer.txt
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • Access 2000 Database - Use the attached WEEK2_ACCESS2000.mdb database I just need the SQL code, which can be cut and pasted into a word document. 1. Perform an inner join between the BOOKS table and the ORDER_LINE ...
  • Compare the given select queries in terms of the number of hard drive reads. - Here's a query: SELECT orders.order_date, orders.customer_numb FROM orders INNER JOIN order_lines ON orders.order_numb = order_lines.order_numb WHERE order_lines.isbn = '0-131-496 ...
  • Running a Query - Why wont this query run and how would you write it correctly? Major hint: try and run the query (use the database attached to Week 2's lecture) ... you'll get an error message that should explain: ...
  • Query Results - Why wont this query give any results (using the week 2 lecture database)? SELECT orders.order_numb, customers.customer_last_name FROM customers INNER JOIN orders ON customers.customer_numb = cus ...
  • Query Results - RIGHT Outer Join - Using the week 2 lecture database, if you wanted to see all the isbns from the books table and any matching isbns from the order_lines table, you'd want to do an outer join as such (because not every ...
Browse