Solved

Select statement not working when MAX function is used.

Posted on 2013-11-22
1
333 Views
Last Modified: 2013-11-22
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
Comment
Question by:tesla764
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39669635
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question