troubleshooting Question

Group By Function in SQL

Avatar of Kyle Witter
Kyle WitterFlag for United States of America asked on
Microsoft SQL Server
1 Comment1 Solution264 ViewsLast Modified:
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

ASKER CERTIFIED SOLUTION
ralmada

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros