We help IT Professionals succeed at work.
Get Started

Top 5 Query MySql with Caveat

badtenant asked
Last Modified: 2012-05-09
I'm having a hard time worth my query...I know how to get the top 5 sales but I'm having issues trying to get the previous year sales included and sorted in the query. I want to sort the stores by the 2010 totals and only show 2009 as a reference and it should have no bearing on the sort.

Example. Table: Store, Amount, Year
Store 10 1000.00 2010
Store 10 500.00 2009
Store 46 997.00 2010
Store 46 1500.00 2009
Store 5 850.00 2010
Store 5 430.00 2009
Store 99 777.00 2010
Store 99 401.00 2009
Store 101 550.00 2010
Store 101 700.00 2009
Watch Question
This problem has been solved!
Unlock 1 Answer and 3 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