'sql counting of uniqueid
I have 1 table Order with columns
CustomerID, TransactionNo, OrderYear, Sales
I need to return the number of new CustomerID and total number of transaction every year of unique customer and the total sales for the order per unique customer.
ex. CustomerID TransactionNo, OrderYear, Sales
| Customer ID | TransactionNo | OrderYear | Sales |
|---|---|---|---|
| 1 | 30375 | 2009 | 10 |
| 2 | 37151 | 2010 | 20 |
| 2 | 37152 | 2011 | 30 |
| 3 | 37153 | 2010 | 40 |
| 5 | 73154 | 2012 | 50 |
| 6 | 37151 | 2013 | 60 |
| 2 | 80808 | 2014 | 70 |
| 4 | 90909 | 2015 | 80 |
| 4 | 10101 | 2015 | 90 |
| 5 | 20200 | 2016 | 20 |
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
