Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
matta0990
Starting Member
44 Posts |
Posted - 2011-10-11 : 05:30:00
|
| Hi, i wanna group by J.Volume in this query but i get "Column 'Entrader.Trade.Total_Volume' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."Any ideas of how to solve this, i no that putting it into a CASE statment should solve it but not sure where to put the CASE.SELECT A.Total_Volume as Tonnage, Actual_Volume_Total, Planned_Discharge as ETA, A.Trade_Id,B.Product_Code as Fuel,C.Identifier as Vessel, Status,F.Location_Name as Delivery_Port,J.Volume as Stock_Movement,H.Str_Value as OriginFROM Entrader.Trade Ainner join Entrader.Product Bon B.Product_Id = A.Product_Idinner join Entrader.Transport_Unit Con C.Transport_Unit_Id = A.Transport_Unit_Idinner join Entrader.Commodity Don D.Commodity_Id = A.Commodity_Idinner join Entrader.Stock_Transaction Ion I.Trade_Id = A.Trade_Idinner join Entrader.Stock_Movement Jon J.Stock_Movement_Id = I.Stock_Movement_Idleft join core.Location Eon E.Location_Id = A.Load_Location_Id left join core.Location Fon F.Location_Id = A.Discharge_Location_Idleft join core.Address Gon G.Address_Id = E.Address_Idleft join core.Reference_Entry Hon H.Reference_Entry_Id = G.Country_Idwhere Trade_Type = 'Vessel'and Planned_Discharge >= DATEADD(DAY, DATEDIFF(DAY,0,GETDATE()-30),0) and Planned_Discharge <= DATEADD(DAY, DATEDIFF(DAY,0,GETDATE()+14),0)and Commodity_Name = @Commodity_Nameand F.Location_Name <> @Location_Nameorder by Vessel |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-10-11 : 05:37:20
|
| you need to add all columns in group by if you want to include in select. else you need to apply some kind of aggregation on them. if you can show some sample data and then explain what output you want then we might be able help more.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|