Pivot and Rank in action
- Select Customer ID on left.
- See the second most sales for that customer.
- The query selects the TOP 2 sales into a Temp table.
- A second query selects the TOP 1 sales from the Temp table sorting ascending on the sales count.
|
|
| csrID | Name | ProductID | orderDate | Qty |
| 11176 | Road Tire Tube | 922 | 07/18/2004 | 7 |
|