I have a problem with a query
in a Oracle
database in a table with 3 columns:
ID_Loja | Channel | Sales_Value
There is the possibility of having more than one sale per store and I want to know which channel is assigned to the store based on the amount of sales each store had as per the example below. In this case, I want the query to just return the line containing the "A" channel since in this case 5 sales vs. 4 sales occurred for the same store with a different rating.
ID_Loja: 1
Channel: A
Count (Sales_Value): 5
ID_Loja: 1
Channel: B
Count (Sales_Value): 4
So far, I only made query
which brings the amount of sales per store / channel, but I was not able to only bring the combination that has more sales per store / channel only.
SELECT
ID_Loja, Canal, COUNT(Valor_Venda)
FROM Vendas
GROUP BY ID_loja, Canal
Can you help me?