Click here to Skip to main content
11,438,752 members (76,697 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL
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

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 2-Feb-13 2:31am
Edited 2-Feb-13 2:59am
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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).
  Permalink  
Comments
VijayGujar at 2-Feb-13 7:37am
   
sir ,but i have require "GR_Process_Outward.Material_Code" this field
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Try the following Query:

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 
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Try with this...

 
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...)
  Permalink  

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



Advertise | Privacy | Mobile
Web03 | 2.8.150506.1 | Last Updated 4 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100