group by problem
I have two tables in the database named orders and colorchart
orders:
1.indexno(PK)
2.job_code
3.shipMode
4.exportDate
5.sizeCode
colorchart:
1.indexno(FK)
2.colorCode
3.Qty
I want to retrieve a data as
All fields from the orderstable and sum(qty) from the colorchart for each indexno match.
What is the query.
I have given as
select o.indexno,o.job_code,o.shipMode,o.exportDate,o.siz eCode,sum(cc.qty) as Qty from orders o,colorchart cc group by o.indexno,o.job_code,o.shipMode,o.exportDate,o.siz eCode having o.indexno=cc.indexno order by o.indexno
Displaying error "Tried to execute a query that does not include the specified expression o.indexno=cc.indexno as part of aggregate function"
When i give where clause instead of having its executing fine. But having is to be used with group by clause. The query is as...
select o.indexno,o.job_code,o.shipMode,o.exportDate,o.siz eCode,sum(cc.qty) as Qty from orders o,colorchart cc where o.indexno=cc.indexno group by o.indexno,o.job_code,o.shipMode,o.exportDate,o.siz eCode order by o.indexno
|