We help IT Professionals succeed at work.
Get Started

SQL Query Syntax

325 Views
Last Modified: 2015-05-23
I'm trying to use the GROUP BY statement but I'm getting an error message when I try to execute my query. The error states: Column 'dbo.jomast.fsono' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

Not sure I understand what I'm doing wrong. Can anyone shed some light on this?

Here's the query:

SELECT        J2.fjobno AS JobOrderNo, J2.fsono + LTRIM(RTRIM(J2.fkey)) AS SOKey, I.fcpro_name AS WorkCenterName
FROM            dbo.jodrtg AS J1 INNER JOIN
                         dbo.inwork AS I ON J1.fpro_id = I.fcpro_id INNER JOIN
                         dbo.jomast AS J2 ON J1.fjobno = J2.fjobno
WHERE        (I.fcpro_name LIKE '%-G%')
GROUP BY J2.fjobno

Open in new window

Comment
Watch Question
Database and Application Developer
Commented:
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE