Search
 
SCRIPT & CODE EXAMPLE
 

SQL

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);
Comment

PREVIOUS NEXT
Code Example
Sql :: mysql database is not starting in xampp 
Sql :: mysql database create 
Sql :: postgres check for foreign key 
Sql :: how to find sql server agent jobs related to a database 
Sql :: sql trim whitespace 
Sql :: sql drop default 
Sql :: sql delete row with auto increment 
Sql :: check constraint in sql 
Sql :: concat column data in sql laravel 
Sql :: postgresql add leading zeros 
Sql :: mysql update with subquery 
Sql :: like in mysql 
Sql :: phpmyadmin reset root password 
Sql :: postgresql set auto increment value 
Sql :: oracle show procedures 
Sql :: mysql replace remove html tag 
Sql :: create index mysql cli 
Sql :: oracle sql select all days between two dates except weekends 
Sql :: oracle case 
Sql :: sql drop column 
Sql :: mysql record group by created date count 
Sql :: update and replace mysql 
Sql :: encrypt password postgresql 
Sql :: get foreign table names mysql 
Sql :: drop all tables in azure sql database 
Sql :: sqlite get last 
Sql :: adding generated time in row mysql workbench 
Sql :: sql create database 
Sql :: psql load dump 
Sql :: oracle index hint 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =