chris burgess wrote:
> i need to get the highest and second highest values in a column,
> preferably in the same query. i think this could be done with a
> VIEW by combining the two queries, but i'd like to know if it can be
> done in MySQL.
> i want to return the highest value of X, and a value calculated off
> the second highest value of X. for example, the last time a safety
> check was made, and the time one week after the previous check, but
> the date aspect is unimportant. i'd like to get them in as this_X and
> last_X in a single row.
> at the same time i'll be retrieving other information from the row
> this_X lives in, and getting data from other JOINed tables. the only
> thing i need from last_X row is last_X.
> can this be done with a single response row answer?
Try something like this:
select a from my_table order by a desc limit 2