We help IT Professionals succeed at work.

SQL Script Issue?

I have a very simple SQL Script which I'm trying to modify. I have attached a screenshot of the resulting query as well as the desired query and it's results. Below is the actual query:

SELECT	creep_ID,
		runNO,
		intervalPoint,
		output,
		[error],
		printOnCert
  FROM	TEST_DETAILS_Creep 
 WHERE	creep_ID = 230

Open in new window

Screenshot.jpg
Screenshot2.jpg
Comment
Watch Question

IT Engineer
Distinguished Expert 2017
Commented:
When you use an aggregate function (MIN, MAX, COUNT, SUM) you need to add the rest of the columns in the SELECT into the GROUP BY clause:
SELECT creep_ID,
		runNO,
		intervalPoint,
		output,
		[error],
		printOnCert,
               MAX(runNO)
  FROM	TEST_DETAILS_Creep 
 WHERE	creep_ID = 230
GROUP BY creep_ID,
		runNO,
		intervalPoint,
		output,
		[error],
		printOnCert

Open in new window

Author

Commented:
That worked Vitor...thank you!