japeconsulting
Programmer
I need a sql command that can show the first delivery type for each customer and I have managed to achieve this with OVER PARTITION BY using ROW NUMBER 1 but I also need a distinct count for each order and apparently this is not possible with this clause. Can anyone come up with a a simple sql command I can use for both.
Example as follows:
Customer ID Order ID Delivery Type Order Date
1.00 1 Pickup 26/01/2005
1.00 1 Parcel Post 30/01/2005
1.00 1 UPS 02/02/2005
1.00 2 Loomis 04/02/2005
1.00 2 Loomis 28/02/2005
1.00 3 FedEx 09/04/2005
2.00 4 Loomis 07/01/2005
2.00 4 Loomis 15/01/2005
2.00 4 FedEx 29/01/2005
2.00 5 Loomis 29/01/2005
2.00 5 Pickup 13/02/2005
Results needed are:
Customer ID Distinct Count of orders Delivery type entry for first order date First Order Date
1.00 3 Pickup 26/01/2005
2.00 2 Loomis 07/01/2005
Thanks
Jackie
Example as follows:
Customer ID Order ID Delivery Type Order Date
1.00 1 Pickup 26/01/2005
1.00 1 Parcel Post 30/01/2005
1.00 1 UPS 02/02/2005
1.00 2 Loomis 04/02/2005
1.00 2 Loomis 28/02/2005
1.00 3 FedEx 09/04/2005
2.00 4 Loomis 07/01/2005
2.00 4 Loomis 15/01/2005
2.00 4 FedEx 29/01/2005
2.00 5 Loomis 29/01/2005
2.00 5 Pickup 13/02/2005
Results needed are:
Customer ID Distinct Count of orders Delivery type entry for first order date First Order Date
1.00 3 Pickup 26/01/2005
2.00 2 Loomis 07/01/2005
Thanks
Jackie