[HW 3.5b] Intermediate SQL – Subselects

Using your “complete and verbose” dataset from yesterday, report on the following:

1. Create a summary of sales by employee.
Copy the results into a spreadsheet.  Label the headings and include a total at the bottom.

The answer for #1 should look like this:

3.5.1

2. Create a summary of sales by product for the month of June 2013
Copy the results into a spreadsheet.  Label the headings and include a total at the bottom.

The answer for #2 should look like this:

3.5.2

3. Create a summary of sales by customer for the month of August 2013 in the North Region
Your summary should have the following columns:

  • Product Name
  • Total Sales Amount (in dollars)
  • Total Number of Transactions
  • Average Transaction Amount

Copy the results into a spreadsheet and include a totals at the bottom for each of these three computed fields.

The answer for #3 should look like this:

3.5.3

 

8 comments

  1. barroyo2015 · · Reply

    How are we supposed to calculate sales within the mysql system? Are you expecting us to add a new column that represents the sum of each transcation sale (quantity * amount)? If so, where can we find that function/command?

    Like

  2. I suppose you could do it that way. However, there is a field on the transaction table which represents the amount of the transaction. It should be called txn_amount.

    Like

    1. barroyo2015 · · Reply

      Yes, I saw that and figured out that it represented the entire amount for that transaction. Now my question is how to group the employee names together and adding up all their transaction amounts. The SUM command returns a much smaller number (possibly the average) so I’m not sure where to go from here.

      Like

      1. Take a look at the class notes.

        Like

  3. Some people seem to be having trouble with this.
    Here are the first few lines of what the answer should look like.
    Product Total Dollar Value of Transactions Transactions Avg Transaction Value
    Ambrosia 1,992 7 284.58
    Angel Delight 2,159 6 359.78
    Apple 1,685 7 240.65
    Apple Crings 1,323 14 94.50
    Avocado 1,495 6 249.11

    Like

  4. Jason, your answer summarises the table by product name but the question asks us to summarise by customer. This is confusing, some clarification?

    Like

  5. Zaghie, I’ve added some pictures showing what the answers should look like. I hope this clarifies it.

    Like

Leave a comment