I have two tables.
Table: Pedido
- Columns:
IDPEDIDO
,CLIENTE
,DT_PEDIDO
,FORMA_PGMT
,CLIENTE_ID
.
Table: Itens_Pedido
- Columns:
PEDIDO_ID
,QT_MERCADORIAS
,MERCADORIA
,MERCADORIA_ID
.
I need to create a query to know which product sold the most in the months of January and February 2015. I did the following query but it is returning this error:
"not a single-group group function"
Inquiry:
Select max(sum(ITENS_PEDIDO.QT_MERCADORIA)),
ITENS_PEDIDO.MERCADORIA
From ITENS_PEDIDO
Join PEDIDO
On ITENS_PEDIDO.PEDIDO_ID = PEDIDO.IDPEDIDO
Group By ITENS_PEDIDO.MERCADORIA_IDMERCADORIA,
ITENS_PEDIDO.MERCADORIA,
PEDIDO.DT_PEDIDO
Having PEDIDO.DT_PEDIDO Between to_date('01/01/2015', 'DD/MM/YYYY')
And to_date('28/02/2015', 'DD/MM/YYYY');