Link to home
Get AccessLog in
Avatar of Kyle Witter
Kyle WitterFlag for United States of America

asked on

Group By Function in SQL

I'm trying to create a view in MS SQL Management Studio, that groups data by two variables, but am having difficulty doing so.  As with my experience with PHP/SQL you can group by a column with little effort, but I continue to get an error that says "Column'dbo.Delivery.Job' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

Basically I'm looking to remove duplicate entries in the outputted data, and if I could group by dbo.Job_Operation.Operation_Service & dbo.Job_Operation.Description it should eliminate the problem.  Attached is my current SQL Code.

Thank You!
SELECT     dbo.Delivery.Job, dbo.Delivery.Shipped_Date, dbo.Delivery.Shipped_Quantity, dbo.Job.Part_Number, dbo.Job.Description, dbo.Work_Center.Work_Center, 
                      dbo.Job_Operation.Operation_Service, dbo.Job_Operation.Description AS Route_Disc, dbo.Job_Operation.Est_Labor_Burden, 
                      dbo.Job_Operation.Est_Machine_Burden, dbo.Job_Operation.Est_GA_Burden, dbo.Job.Est_Labor, dbo.Job_Operation.Act_Labor_Burden, 
                      dbo.Job_Operation.Act_Machine_Burden, dbo.Job_Operation.Act_GA_Burden, dbo.Job.Act_Labor
FROM         dbo.Job INNER JOIN
                      dbo.Job_Operation ON dbo.Job.Job = dbo.Job_Operation.Job INNER JOIN
                      dbo.Job_Operation_Time ON dbo.Job_Operation.Job_Operation = dbo.Job_Operation_Time.Job_Operation INNER JOIN
                      dbo.Work_Center ON dbo.Job_Operation.Work_Center = dbo.Work_Center.Work_Center INNER JOIN
                      dbo.Delivery ON dbo.Job.Job = dbo.Delivery.Job

Open in new window

Avatar of ralmada
Flag of Canada image

Link to home
This content is only available to members.
To access this content, you must be a member of Experts Exchange.
Get Access