devxlogo

SQL: querying records based on ORDER BY

SQL: querying records based on ORDER BY

Question:
Can you make a query that returns records based on ORDER BY something? There may be mutiple instances, but I only want the one that is the very first based on what you ordered by.

Answer:
Well, this seems to ask for a MAX or a MIN of something, but that brings aggregates into the picture. Try:

select max(title_id)from titleauthor group by title_idorder by max(title_id)

devx-admin

Share the Post: