Error group by Oracle

1

When I try to do this group by in oracle it returns me message saying that this is not an expression group by

SELECT produto.cd_produto, produto.ds_produto, est_pro.cd_estoque,
      estoque.ds_estoque, fornecedor.cd_fornecedor,
      fornecedor.nm_fornecedor, prod_atend.cd_lote,
      prod_atend.dt_validade, est_pro.qt_estoque_atual,
      itent_pro.QT_ATENDIDA, ent_pro.nr_documento
 FROM produto, estoque, fornecedor, est_pro, prod_atend, ent_pro, itent_pro
WHERE produto.cd_produto = est_pro.cd_produto
  AND fornecedor.cd_fornecedor = produto.cd_ultimo_fornecedor
  AND prod_atend.cd_produto = produto.cd_produto
  AND estoque.cd_estoque = est_pro.cd_estoque
  AND ITENT_PRO.CD_ENT_PRO = ENT_PRO.CD_ENT_PRO
  AND ITENT_PRO.CD_PRODUTO = PRODUTO.CD_PRODUTO
  AND est_pro.cd_estoque = '15'
  group by produto.CD_PRODUTO, produto.DS_PRODUTO;
    
asked by anonymous 22.05.2015 / 17:06

2 answers

0

From the documentation at link :

  

SelectItems in the SelectExpression with a GROUP BY clause should contain only aggregates or grouping columns.

That is, ALL columns in your select must be part of GROUP BY or have an aggregate function such as AVG() or FIRST() .

This is because the database engine does not know that there is only one est_pro.cd_estoque for each group it makes, and if there is more than one it does not. Then you can use, for example SUM(est_pro.cd_estoque) . This is true for all the columns you want to select.

    
22.05.2015 / 17:25
0

Pedro from what I saw in your select you are trying to group only by code and product description. But in the group by function you need to put all the fields that are in the select

    
22.05.2015 / 17:27