Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 337
  • Last Modified:

Select statement not working when MAX function is used.

I get the following error when I execute the SELECT statement seen below...

You tried to execute a query that does not inclue the specified expression 'questioncode' as part of an aggregate function.

SELECT questioncode, MAX(regulatoryanswer), inpracticeresponse from vmasterdata where questioncode = 'GQ-005' and regulatoryanswer like "*Day*" or regulatoryanswer like "*Month*"

I am trying to get the largest value in the regulatory column.

This statement works fine without the MAX.

Could somebody help with this and tell me what I am doing wrong?

Thanks.
0
tesla764
Asked:
tesla764
1 Solution
 
Rey Obrero (Capricorn1)Commented:
try this


SELECT questioncode, MAX(regulatoryanswer), inpracticeresponse from vmasterdata where questioncode = 'GQ-005' and regulatoryanswer like "*Day*" or regulatoryanswer like "*Month*"
group by questioncode, inpracticeresponse
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now