SQL: Top (Latest) Item Per Group

I spent far too long this morning on trying to find a solution to this SQL problem.
Consider the PERSON table:

Location Name Age
London Fred 45
London Mark 35
London Mike 25
Cardiff Jim 56
Cardiff Julia 46
Cardiff Murray 36
Edinburgh Sheila 61
Edinburgh Launa 51
Edinburgh Lin 41

Suppose you want the name of the oldest person at each location. How do you achieve this in SQL?

Like this:

The result should be:

Location Name Age
London Fred 45
Cardiff Jim 56
Edinburgh Sheila 61

Thanks to Findy Services and B. Jacobs for this solution.

Hello World

Remember how it all began?


Hello World
Hello World
Hello World
Hello World
Hello World
...

And the world’s reply?

...
...
...

Nothing. Null. Nada. Tumble-weed.

But I’m not worried. That’s how greatness starts!

  • Number 1 on Einstein‘s list of achievements was learning to count.
  • Once upon a time even Tolkien had to learn his ABCs.
  • The first step to success for Roger Bannister was learning to walk.

We all have to start somewhere.

As the wise have said:

  • Despise not the day of small beginnings
  • Every journey begins with a single step
  • Rome wasn’t built in a day

There are, then, just two things that make up greatness:

  • The courage to get started
  • The tenacity to keep getting better

So, here I go:

  • I’ll do something worthwhile today
  • I’ll aim to do it better than I did it yesterday
  • And in so doing I’ll learn something for tomorrow

In the mean time, I raise a glass to you, “Hello world”.

It may seem childish now, but it will grow up soon enough.