0
I am working with Oracle database and PHP, need to return only one product each with the latest change date, the tables are as follows.
product
price
I have tried several types of query, but I always get duplicate results.
And trying to group with the following query
SELECT a.CODPROD, a.DESCRICAO, b.PVENDA, b.CODPROD FROM PCPRODUT a, PCPRECO b
GROUP BY b.CODPROD
I get the following error:
"ORA-00979: not a GROUP BY expression"
Tried to group the query? how you tried the query?
– rray
When I try to group I get the following error: "ORA-00979: not a GROUP BY expression"
– Jonathan Mauer
A consulta é "SELECT
 CODPROD,
 DESCRICAO, 
 PVENDA
 
FROM
 PCPRODUT, PCPRECO WHERE PCPRODUT.CODPROD = PCPRECO.CODPROD"
– Jonathan Mauer
Edith the question and put the query you tried with the group by
– rray
All the columns that are in
select
must be in thegroup by
– rray
I performed the following query now, but the page is just clicking and does not return anything. "a. CODPROD, a.DESCRICAO, b.PVENDA, b.CODPROD, max(b.DATAALTER) FROM PCPRODUT a, PCPRECO b GROUP BY a.CODPROD, a.DESCRICAO, b.PVENDA, b.CODPROD"
– Jonathan Mauer
When you test on the bench you get the desired result?
– rray
No, the same thing happens
– Jonathan Mauer