Sql select second max

This article is tagged with: Sql select second max and mysql

sql select second max

Both options you find max as a subset and then exclude from main select
sql> SELECT MAX( col ) FROM table
WHERE col < ( SELECT MAX( col ) FROM table);
sql> SELECT MAX(col) FROM table
WHERE col NOT IN (SELECT MAX(col) FROM table);

This article is tagged with: Sql select second max and mysql