Click here to Skip to main content
15,896,437 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

i'm writing following Sql statement but it raises an error like

"Column 'GR_Process_Outward.Material_Code' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."

-->i m require "GR_Process_Outward.Material_Code" field

My sql statement is

SQL
select Product_Material_Master.Product_Name, SUM(GR_Process_Outward.Qty),GR_Process_Outward.Material_Code
from Product_Material_Master,GR_Process_Outward
where Product_Material_Master.Product_Code=GR_Process_Outward.Product_Code
AND Receipt_No=5 GROUP BY Product_Name


pls help me.pls

thanks in advance
Posted
Updated 2-Feb-13 1:59am
v4

You need to remove GR_Process_Outward.Material_Code from your GROUP BY query or move it into the GROUP BY clause (which will lead to different results).
 
Share this answer
 
Comments
VijayGujar 2-Feb-13 7:37am    
sir ,but i have require "GR_Process_Outward.Material_Code" this field
Try the following Query:

SQL
select Product_Material_Master.Product_Name, SUM(GR_Process_Outward.Qty),GR_Process_Outward.Material_Code
from Product_Material_Master,GR_Process_Outward
where Product_Material_Master.Product_Code=GR_Process_Outward.Product_Code
AND Receipt_No=5 GROUP BY Product_Material_Master.Product_Name, GR_Process_Outward.Material_Code 
 
Share this answer
 
Try with this...

SQL
select Product_Material_Master.Product_Name, SUM(GR_Process_Outward.Qty),GR_Process_Outward.Material_Code
from Product_Material_Master,GR_Process_Outward
where Product_Material_Master.Product_Code=GR_Process_Outward.Product_Code
AND Receipt_No=5 
GROUP BY Product_Name,Material_Code



whenever you used the Group function definately you can call all the columns whatever you select in select query except that aggregate functions like( sum, avg...)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900