B
Ben
Hi all,
I have a SQL question. I have a table which contain fields:
Product, Customer and SpendByCustomer
What I would like is to create a query of the top spend by customers
(aggregated) by Product. I would like the query list by Product, then by
the top spend customer (in descending order) and a new field that would
tag it as such. For example:
Product Customer Spend Order
1 ABC 1000 5
1 CDE 500 4
1 FGH 400 3
1 IJK 300 2
1 LMN 100 1
2 FGH 400 3
2 CDE 100 2
2 ABC 50 1
The value of the Order field is based on number of customers for that
particular product. Within that sub-group of customer for that
particular product, the value of Order is sorted by the top spend of
that customer for that product.
Can you please help me with some ideas/ SQL code snippets?
Thanks in advance,
Ben
I have a SQL question. I have a table which contain fields:
Product, Customer and SpendByCustomer
What I would like is to create a query of the top spend by customers
(aggregated) by Product. I would like the query list by Product, then by
the top spend customer (in descending order) and a new field that would
tag it as such. For example:
Product Customer Spend Order
1 ABC 1000 5
1 CDE 500 4
1 FGH 400 3
1 IJK 300 2
1 LMN 100 1
2 FGH 400 3
2 CDE 100 2
2 ABC 50 1
The value of the Order field is based on number of customers for that
particular product. Within that sub-group of customer for that
particular product, the value of Order is sorted by the top spend of
that customer for that product.
Can you please help me with some ideas/ SQL code snippets?
Thanks in advance,
Ben