By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,387 Members | 1,713 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,387 IT Pros & Developers. It's quick & easy.

How to get the last row in from multiple groups of data?

P: 167
I am running windows xp, ms office 2000. I have an application that has data that looks like this:
Expand|Select|Wrap|Line Numbers
  1. FuelType  Year   State   (column names,all keys, so no dups allowed)
  2. Diesel    1999     NC
  3. Diesel    2000     NC
  4. Diesel    2001     NC
  5. Gas       1998     SC
  6. Gas       1999     SC
  7. Gas       2000     SC
What I am trying to do is to select the last row in the each set of keys, basically, I want one row for each FuelType, Year & State. So, for NC, I would get the row for Diesel 2001, for SC I would get Gas for 2000. Maybe I am over compliating this but I am trying to use the 'max' function and can not get the results I need. There are other columns of data on the record I will need once I can determine which is the last row for this grouping. Any guidance would be appreciated!!!!
Sep 5 '08 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 15k+
P: 31,662
This is possible. Unfortunately your example seems to contradict your explanation, so I'm not sure what you're after here (Is it max year for each FuelType / State combination? Or max FuelType / Year for each State as per your example explanations?).

Please clarify and then we can proceed.
Sep 5 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.