Sunday, January 19, 2014

Chapter 5 homework Lesson 1, grouping and windowing

Chapter 5 homework Lesson 1:

1) Two Tables with fields:
ID  Name
--  -------
1   Alpha
2   Beta
3   Beta
4   Beta
5   Charlie
6   Charlie
I want to group them by name, with 'count', and a row 'SUM' so that they look like the following:
Name     Count
-------  -----
Alpha     1
Beta      3
Charlie   2
SUM       6
How would I write a query to add SUM row below the table?
Answer: http://stackoverflow.com/questions/12927268/sum-of-grouped-count-in-sql-query

2)
Write a query that groups the number of rows by shipperid and count the number of rows (orders in this case) per each distinct group.  Use sales.orders
Answer: page 151

3)
Write a query that returns shipped orders by shipperid and shipping year, and filter only groups having fewer than 100 orders.  Use Table sales.orders
Answer: page 152

4)
Exercises in book

No comments:

Post a Comment