Avatar of Lawrence Salvucci
Lawrence SalvucciFlag for United States of America

asked on 

SQL Query Syntax

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

Microsoft SQL ServerSQL

Avatar of undefined
Last Comment
Mike Eghtebas
ASKER CERTIFIED SOLUTION
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo