We help IT Professionals succeed at work.
Get Started

You tried to execute a query that does not include the specified expression 'Left(ID,InStr(ID&'-','-')-1)' as part of an aggregate function.

2,264 Views
Last Modified: 2012-05-05
Hi,

Extension of question from https://www.experts-exchange.com/Database/Miscellaneous/Q_23580695.html

Now I have a table:

Num   ID
---------------
1   123
2   123
3   123-X
4   888-X
5   333
6   333-X

I got the error when execute the SQL command.

You tried to execute a query that does not include the specified expression 'Left(ID,InStr(ID&'-','-')-1)' as part of an aggregate function.

How can I resolve it?
SELECT Left(ID,InStr(ID&'-','-')-1) AS N, MIN(Num) AS minrec FROM info GROUP BY info.N ORDER BY info.N

Open in new window

Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
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