Dan Goodspeed
Dan Goodspeed

Reputation: 3560

SQLite limit different column then order results

Let's say I have a table of a few hundred names and ages. I want to query the 100 youngest people like

SELECT name, age FROM people ORDER BY age ASC LIMIT 100

But what if I wanted the results to come back sorted by name? Is there an easy way to do that?

Upvotes: 0

Views: 35

Answers (1)

wallyk
wallyk

Reputation: 57774

The syntax is probably wrong here, but it is something along the lines of:

SELECT * FROM
  (SELECT name, age FROM people ORDER BY age ASC LIMIT 100)
ORDER by name

Upvotes: 4

Related Questions