<p>What is the simplest SQL query to find the second largest integer value in a specific column? </p>

<p>There are maybe duplicate values in the column.</p>

[{'answer_id': 32108, 'author': 'Magnar', 'author_id': 1123, 'author_profile': 'https://Stackoverflow.com/users/1123', 'pm_score': 3, 'selected': False, 'text': '<p>The easiest would be to get the second value from this result set in the application:</p>\n<pre><code>SELECT DISTINCT value \nFROM Table \nORDER BY value DESC \nLIMIT 2\n</code></pre>\n<p>But if you must select the second value using SQL, how about:</p>\n<pre><code>SELECT MIN(value) \nFROM ( SELECT DISTINCT value \n       FROM Table \n       ORDER BY value DESC \n       LIMIT 2\n     ) AS t\n</code></pre>\n'}, {'answer_id': 32109, 'author': 'dguaraglia', 'author_id': 2384, 'author_profile': 'https://Stackoverflow.com/users/2384', 'pm_score': 4, 'selected': False, 'text': "<p>I suppose you can do something like:</p>\n<pre><code>SELECT * \nFROM Table \nORDER BY NumericalColumn DESC \nLIMIT 1 OFFSET 1\n</code></pre>\n<p>or</p>\n<pre><code>SELECT * \nFROM Table ORDER BY NumericalColumn DESC \nLIMIT (1, 1)\n</code></pre>\n<p>depending on your database server. Hint: SQL Server doesn't do LIMIT.</p>\n"}, {'answer_id': 32111, 'author': 'Matt Rogish', 'author_id': 2590, 'author_profile': 'https://Stackoverflow.com/users/2590', 'pm_score': 9, 'selected': True, 'text': '<pre><code>SELECT MAX( col )\n  FROM table\n WHERE col &lt; ( SELECT MAX( col )\n                 FROM table )\n</code></pre>\n'}, {'answer_id': 32114, 'author': 'Chris Conway', 'author_id': 2849, 'author_profile': 'https://Stackoverflow.com/users/2849', 'pm_score': 0, 'selected': False, 'text': '<pre><code>select top 1 MyIntColumn from MyTable\nwhere\n MyIntColumn &lt;&gt; (select top 1 MyIntColumn from MyTable order by MyIntColumn desc)\norder by MyIntColumn desc\n</code></pre>\n'}, {'answer_id': 32115, 'author': 'Tom Welch', 'author_id': 1188, 'author_profile': 'https://Stackoverflow.com/users/1188', 'pm_score': 0, 'selected': False, 'text': '<p>This works in MS SQL:</p>\n\n<pre><code>select max([COLUMN_NAME]) from [TABLE_NAME] where [COLUMN_NAME] &lt; \n ( select max([COLUMN_NAME]) from [TABLE_NAME] )\n</code></pre>\n'}, {'answer_id': 32119, 'author': 'doekman', 'author_id': 56, 'author_profile': 'https://Stackoverflow.com/users/56', 'pm_score': 0, 'selected': False, 'text': "<p>Something like this? I haven't tested it, though:</p>\n\n<pre><code>select top 1 x\nfrom (\n  select top 2 distinct x \n  from y \n  order by x desc\n) z\norder by x\n</code></pre>\n"}, {'answer_id': 32233, 'author': 'Keith', 'author_id': 905, 'author_profile': 'https://Stackoverflow.com/users/905', 'pm_score': 5, 'selected': False, 'text': "<p>In T-Sql there are two ways:</p>\n\n<pre><code>--filter out the max\nselect max( col )\nfrom [table]\nwhere col &lt; ( \n    select max( col )\n    from [table] )\n\n--sort top two then bottom one\nselect top 1 col \nfrom (\n    select top 2 col \n    from [table]\n    order by col) topTwo\norder by col desc \n</code></pre>\n\n<p>In Microsoft SQL the first way is twice as fast as the second, even if the column in question is clustered.</p>\n\n<p>This is because the sort operation is relatively slow compared to the table or index scan that the <code>max</code> aggregation uses.</p>\n\n<p>Alternatively, in Microsoft SQL 2005 and above you can use the <code>ROW_NUMBER()</code> function:</p>\n\n<pre><code>select col\nfrom (\n    select ROW_NUMBER() over (order by col asc) as 'rowNum', col\n    from [table] ) withRowNum \nwhere rowNum = 2\n</code></pre>\n"}, {'answer_id': 32284, 'author': 'Graeme Perrow', 'author_id': 1821, 'author_profile': 'https://Stackoverflow.com/users/1821', 'pm_score': 0, 'selected': False, 'text': '<p>See <a href="https://stackoverflow.com/questions/16568">How to select the nth row in a SQL database table?</a>.</p>\n\n<p>Sybase SQL Anywhere supports:</p>\n\n<pre><code>SELECT TOP 1 START AT 2 value from table ORDER BY value\n</code></pre>\n'}, {'answer_id': 32393, 'author': 'Joel Coehoorn', 'author_id': 3043, 'author_profile': 'https://Stackoverflow.com/users/3043', 'pm_score': 5, 'selected': False, 'text': '<p>I see both some SQL Server specific and some MySQL specific solutions here, so you might want to clarify which database you need.  Though if I had to guess I\'d say SQL Server since this is trivial in MySQL.</p>\n<p>I also see some solutions that won\'t work because they fail to take into account the possibility for duplicates, so be careful which ones you accept.  Finally, I see a few that will work but that will make two complete scans of the table.  You want to make sure the 2nd scan is only looking at 2 values.</p>\n<p>SQL Server (pre-2012):</p>\n<pre><code>SELECT MIN([column]) AS [column]\nFROM (\n    SELECT TOP 2 [column] \n    FROM [Table] \n    GROUP BY [column] \n    ORDER BY [column] DESC\n) a\n</code></pre>\n<p>MySQL:</p>\n<pre><code>SELECT `column` \nFROM `table` \nGROUP BY `column` \nORDER BY `column` DESC \nLIMIT 1,1\n</code></pre>\n<p><strong>Update:</strong></p>\n<p>SQL Server 2012 now supports a much cleaner (and <a href="http://en.wikipedia.org/wiki/SQL:2011" rel="nofollow noreferrer"><em>standard</em></a>) OFFSET/FETCH syntax:</p>\n<pre><code>SELECT [column] \nFROM [Table] \nGROUP BY [column] \nORDER BY [column] DESC\nOFFSET 1 ROWS\nFETCH NEXT 1 ROWS ONLY;\n</code></pre>\n'}, {'answer_id': 1101910, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<pre><code>select * from emp e where 3&gt;=(select count(distinct salary)\n    from emp where s.salary&lt;=salary)\n</code></pre>\n\n<p>This query selects the maximum three salaries. If two emp get the same salary this does not affect the query.</p>\n'}, {'answer_id': 1423692, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>Using a correlated query:</p>\n\n<pre><code>Select * from x x1 where 1 = (select count(*) from x where x1.a &lt; a)\n</code></pre>\n'}, {'answer_id': 4279304, 'author': 'sunith', 'author_id': 520440, 'author_profile': 'https://Stackoverflow.com/users/520440', 'pm_score': 1, 'selected': False, 'text': '<p>Tom, believe this will fail when there is more than one value returned in <code>select max([COLUMN_NAME]) from [TABLE_NAME]</code> section. i.e. where there are more than 2 values in the data set.</p>\n<p>Slight modification to your query will work -</p>\n<pre><code>select max([COLUMN_NAME]) \nfrom [TABLE_NAME] \nwhere [COLUMN_NAME] IN ( select max([COLUMN_NAME]) \n                         from [TABLE_NAME] \n                       )\n</code></pre>\n'}, {'answer_id': 4279338, 'author': 'sunith', 'author_id': 520440, 'author_profile': 'https://Stackoverflow.com/users/520440', 'pm_score': 1, 'selected': False, 'text': '<pre><code>select max(COL_NAME) \nfrom TABLE_NAME \nwhere COL_NAME in ( select COL_NAME \n                    from TABLE_NAME \n                    where COL_NAME &lt; ( select max(COL_NAME) \n                                       from TABLE_NAME\n                                      )\n                   );\n</code></pre>\n<p>subquery returns all values other than the largest.\nselect the max value from the returned list.</p>\n'}, {'answer_id': 6967041, 'author': 'Ni3', 'author_id': 881951, 'author_profile': 'https://Stackoverflow.com/users/881951', 'pm_score': 1, 'selected': False, 'text': '<pre><code>select min(sal) from emp where sal in \n    (select TOP 2 (sal) from emp order by sal desc)\n</code></pre>\n\n<p>Note</p>\n\n<p>sal is col name<br>\nemp is table name</p>\n'}, {'answer_id': 7362165, 'author': 'Vinoy', 'author_id': 936824, 'author_profile': 'https://Stackoverflow.com/users/936824', 'pm_score': 6, 'selected': False, 'text': '<pre><code>SELECT MAX(col) \nFROM table \nWHERE col NOT IN ( SELECT MAX(col) \n                   FROM table\n                 );\n</code></pre>\n'}, {'answer_id': 9939606, 'author': 'Divya.N.R', 'author_id': 1302822, 'author_profile': 'https://Stackoverflow.com/users/1302822', 'pm_score': 1, 'selected': False, 'text': "<pre><code>select col_name\nfrom (\n    select dense_rank() over (order by col_name desc) as 'rank', col_name\n    from table_name ) withrank \nwhere rank = 2\n</code></pre>\n"}, {'answer_id': 11233270, 'author': 'Rohit Singh', 'author_id': 1486677, 'author_profile': 'https://Stackoverflow.com/users/1486677', 'pm_score': 2, 'selected': False, 'text': '<pre><code>\nselect * from (select ROW_NUMBER() over (Order by Col_x desc) as Row, Col_1\n    from table_1)as table_new tn inner join table_1 t1\n    on tn.col_1 = t1.col_1\nwhere row = 2\n</code></pre>\n\n<p>Hope this help to get the value for any row.....</p>\n'}, {'answer_id': 13034858, 'author': 'avie sparrows', 'author_id': 1768911, 'author_profile': 'https://Stackoverflow.com/users/1768911', 'pm_score': 1, 'selected': False, 'text': '<pre><code>SELECT \n    * \nFROM \n    table \nWHERE \n    column &lt; (SELECT max(columnq) FROM table) \nORDER BY \n    column DESC LIMIT 1\n</code></pre>\n'}, {'answer_id': 13067166, 'author': 'petcy', 'author_id': 1773950, 'author_profile': 'https://Stackoverflow.com/users/1773950', 'pm_score': 3, 'selected': False, 'text': '<p>A very simple query to find the second largest value</p>\n<pre><code>SELECT `Column` \nFROM `Table` \nORDER BY `Column` DESC \nLIMIT 1,1;\n</code></pre>\n'}, {'answer_id': 14473566, 'author': 'user1796141', 'author_id': 1796141, 'author_profile': 'https://Stackoverflow.com/users/1796141', 'pm_score': 3, 'selected': False, 'text': '<p>you can find the second largest value of column by using the following query</p>\n\n<pre><code>SELECT *\nFROM TableName a\nWHERE\n  2 = (SELECT count(DISTINCT(b.ColumnName))\n       FROM TableName b WHERE\n       a.ColumnName &lt;= b.ColumnName);\n</code></pre>\n\n<p>you can find more details on the following link</p>\n\n<p><a href="http://www.abhishekbpatel.com/2012/12/how-to-get-nth-maximum-and-minimun.html">http://www.abhishekbpatel.com/2012/12/how-to-get-nth-maximum-and-minimun.html</a></p>\n'}, {'answer_id': 15609026, 'author': 'nikita', 'author_id': 2206467, 'author_profile': 'https://Stackoverflow.com/users/2206467', 'pm_score': 0, 'selected': False, 'text': '<p>Query to find the 2nd highest number in a row- </p>\n\n<pre><code>select Top 1 (salary) from XYZ\nwhere Salary not in (select distinct TOP 1(salary) from XYZ order by Salary desc)\nORDER BY Salary DESC\n</code></pre>\n\n<p>By changing the highlighted <code>Top 1</code> to <code>TOP 2</code>,  <code>3</code> or <code>4</code> u can find the 3rd, 4th and 5th highest respectively.</p>\n'}, {'answer_id': 16167516, 'author': 'Abhishek Gahlout', 'author_id': 1966824, 'author_profile': 'https://Stackoverflow.com/users/1966824', 'pm_score': 0, 'selected': False, 'text': '<p>We can also make use of order by and top 1 element as follows:</p>\n\n<pre><code>Select  top 1 col_name from table_name\nwhere col_name &lt; (Select top 1 col_name from table_name order by col_name desc)\norder by col_name desc \n</code></pre>\n'}, {'answer_id': 16516669, 'author': 'ReeSen', 'author_id': 2064007, 'author_profile': 'https://Stackoverflow.com/users/2064007', 'pm_score': 0, 'selected': False, 'text': '<pre><code>SELECT * FROM EMP\nWHERE salary=\n        (SELECT MAX(salary) FROM EMP\n           WHERE salary != (SELECT MAX(salary) FROM EMP)\n        );\n</code></pre>\n'}, {'answer_id': 18248613, 'author': 'Pearl90', 'author_id': 2082012, 'author_profile': 'https://Stackoverflow.com/users/2082012', 'pm_score': 1, 'selected': False, 'text': "<p>This is an another way to find the second largest value of a column.Consider the table 'Student' and column 'Age'.Then the query is,</p>\n<pre><code>select top 1 Age \nfrom Student \nwhere Age in ( select distinct top 2 Age  \n               from Student order by Age desc \n             ) order by Age asc\n</code></pre>\n"}, {'answer_id': 18409515, 'author': 'Ravind Maurya', 'author_id': 2388598, 'author_profile': 'https://Stackoverflow.com/users/2388598', 'pm_score': 1, 'selected': False, 'text': '<p>It is the most esiest way:</p>\n\n<pre><code>SELECT\n      Column name\nFROM\n      Table name \nORDER BY \n      Column name DESC\nLIMIT 1,1\n</code></pre>\n'}, {'answer_id': 18763283, 'author': 'Gopal', 'author_id': 2772462, 'author_profile': 'https://Stackoverflow.com/users/2772462', 'pm_score': 0, 'selected': False, 'text': '<p>Try:    </p>\n\n<pre><code>select a.* ,b.* from \n(select * from (select ROW_NUMBER() OVER(ORDER BY fc_amount desc) SrNo1, fc_amount as amount1 From entry group by fc_amount) tbl where tbl.SrNo1 = 2) a\n,\n(select * from (select ROW_NUMBER() OVER(ORDER BY fc_amount asc) SrNo2, fc_amount as amount2  From entry group by fc_amount) tbl where tbl.SrNo2 =2) b\n</code></pre>\n'}, {'answer_id': 20211216, 'author': 'anand', 'author_id': 3035367, 'author_profile': 'https://Stackoverflow.com/users/3035367', 'pm_score': 0, 'selected': False, 'text': '<pre><code>select * from [table] where (column)=(select max(column)from [table] where column &lt; (select max(column)from [table]))\n</code></pre>\n'}, {'answer_id': 22607111, 'author': 'yogesh shelke', 'author_id': 3454959, 'author_profile': 'https://Stackoverflow.com/users/3454959', 'pm_score': 2, 'selected': False, 'text': '<p>Use this query.</p>\n<pre><code>SELECT MAX( colname ) \nFROM Tablename \nwhere colname &lt; (\n    SELECT MAX( colname ) \n    FROM Tablename)\n</code></pre>\n'}, {'answer_id': 23197335, 'author': 'Mitesh Vora', 'author_id': 2153499, 'author_profile': 'https://Stackoverflow.com/users/2153499', 'pm_score': 0, 'selected': False, 'text': '<pre><code>select MAX(salary) as SecondMax from test where salary !=(select MAX(salary) from test)\n</code></pre>\n'}, {'answer_id': 28785160, 'author': 'DEADLOCK', 'author_id': 4554137, 'author_profile': 'https://Stackoverflow.com/users/4554137', 'pm_score': 1, 'selected': False, 'text': '<pre><code>select age \nfrom student \ngroup by id having age&lt; ( select max(age) \n                          from student \n                        )\norder by age \nlimit 1\n</code></pre>\n'}, {'answer_id': 30135366, 'author': 'Naresh Kumar', 'author_id': 4669533, 'author_profile': 'https://Stackoverflow.com/users/4669533', 'pm_score': 2, 'selected': False, 'text': '<pre><code>SELECT MAX(Salary) \nFROM Employee \nWHERE Salary NOT IN ( SELECT MAX(Salary) \n                      FROM Employee \n                    )\n</code></pre>\n<p>This query will return the maximum salary, from the result - which not contains maximum salary from overall table.</p>\n'}, {'answer_id': 32496424, 'author': 'Sumeet', 'author_id': 2347348, 'author_profile': 'https://Stackoverflow.com/users/2347348', 'pm_score': 2, 'selected': False, 'text': '<p>Simplest of all</p>\n<pre><code>select sal \nfrom salary \norder by sal desc \nlimit 1 offset 1\n</code></pre>\n'}, {'answer_id': 35787707, 'author': 'Hiren Joshi', 'author_id': 5784225, 'author_profile': 'https://Stackoverflow.com/users/5784225', 'pm_score': 0, 'selected': False, 'text': '<pre><code>select score \nfrom table \nwhere score = (select max(score)-1 from table)\n</code></pre>\n'}, {'answer_id': 37399687, 'author': 'Zorkolot', 'author_id': 3064345, 'author_profile': 'https://Stackoverflow.com/users/3064345', 'pm_score': 0, 'selected': False, 'text': '<p><strong>Microsoft SQL Server - Using Two TOPs for the N-th highest value (aliased sub-query).</strong></p>\n\n<p>To solve for the 2nd highest:</p>\n\n<pre><code>SELECT TOP 1 q.* \nFROM (SELECT TOP 2 column_name FROM table_name ORDER BY column_name DESC) as q\nORDER BY column_name ASC;\n</code></pre>\n\n<p>Uses TOP twice, but requires an aliased sub-query. Essentially, the inner query takes the greatest 2 values in descending order, then the outer query flips in ascending order so that 2nd highest is now on top. The SELECT statement returns this top.</p>\n\n<p>To solve for the n-th highest value modify the sub-query TOP value. For example:</p>\n\n<pre><code>SELECT TOP 1 q.* \nFROM (SELECT TOP 5 column_name FROM table_name ORDER BY column_name DESC) as q\nORDER BY column_name;\n</code></pre>\n\n<p>Would return the 5th highest value.</p>\n'}, {'answer_id': 38665733, 'author': 'dier', 'author_id': 3605078, 'author_profile': 'https://Stackoverflow.com/users/3605078', 'pm_score': 2, 'selected': False, 'text': '<p>Old question I know, but this gave me a better exec plan:</p>\n\n<pre><code> SELECT TOP 1 LEAD(MAX (column)) OVER (ORDER BY column desc)\n FROM TABLE \n GROUP BY column\n</code></pre>\n'}, {'answer_id': 39304076, 'author': 'Jinto John', 'author_id': 4583281, 'author_profile': 'https://Stackoverflow.com/users/4583281', 'pm_score': 0, 'selected': False, 'text': '<pre><code>select extension from [dbo].[Employees] order by extension desc offset  2  rows fetch next  1 rows only\n</code></pre>\n'}, {'answer_id': 40999700, 'author': 'Shourob Datta', 'author_id': 1705371, 'author_profile': 'https://Stackoverflow.com/users/1705371', 'pm_score': 1, 'selected': False, 'text': '<p>As you mentioned duplicate values . In such case you may use <strong>DISTINCT</strong> and <strong>GROUP BY</strong> to find out second highest value </p>\n\n<p>Here is a table </p>\n\n<blockquote>\n  <p><strong>salary</strong></p>\n</blockquote>\n\n<p>: </p>\n\n<p><a href="https://i.stack.imgur.com/ddP20.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ddP20.png" alt="enter image description here"></a></p>\n\n<blockquote>\n  <p><strong>GROUP BY</strong> </p>\n</blockquote>\n\n<pre><code>SELECT  amount FROM  salary \nGROUP by amount\nORDER BY  amount DESC \nLIMIT 1 , 1\n</code></pre>\n\n<blockquote>\n  <p><strong>DISTINCT</strong> </p>\n</blockquote>\n\n<pre><code>SELECT DISTINCT amount\nFROM  salary \nORDER BY  amount DESC \nLIMIT 1 , 1\n</code></pre>\n\n<p>First portion of LIMIT = starting index </p>\n\n<p>Second portion of LIMIT = how many value </p>\n'}, {'answer_id': 42717600, 'author': 'Swadesh', 'author_id': 7584349, 'author_profile': 'https://Stackoverflow.com/users/7584349', 'pm_score': 1, 'selected': False, 'text': '<pre><code>SELECT MAX(sal) \nFROM emp\nWHERE sal NOT IN ( SELECT top 3 sal \n                   FROM emp order by sal desc \n                 )\n            \n</code></pre>\n<p>this will return the third highest sal of emp table</p>\n'}, {'answer_id': 43452698, 'author': 'Mani G', 'author_id': 4830297, 'author_profile': 'https://Stackoverflow.com/users/4830297', 'pm_score': 0, 'selected': False, 'text': '<p>Very Simple.\nThe distinct keyword will take care of duplicates as well.</p>\n\n<pre><code>SELECT distinct SupplierID FROM [Products] order by SupplierID desc limit 1 offset 1\n</code></pre>\n'}, {'answer_id': 44383572, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>The easiest way to get second last row from a SQL table is to use <code>ORDER BY</code><strong><code>ColumnName</code></strong><code>DESC</code> and set <code>LIMIT 1,1</code>.</p>\n\n<p>Try this:</p>\n\n<pre><code>SELECT * from `TableName` ORDER BY `ColumnName` DESC LIMIT 1,1\n</code></pre>\n'}, {'answer_id': 44715852, 'author': 'Nijish.', 'author_id': 8203886, 'author_profile': 'https://Stackoverflow.com/users/8203886', 'pm_score': 2, 'selected': False, 'text': "<p>This is very simple code, you can try this :-</p>\n\n<p>ex :\nTable name = test</p>\n\n<pre><code>salary \n\n1000\n1500\n1450\n7500\n</code></pre>\n\n<p>MSSQL Code to get 2nd largest value</p>\n\n<pre><code>select salary from test order by salary desc offset 1 rows fetch next 1 rows only;\n</code></pre>\n\n<p>here 'offset 1 rows' means 2nd row of table and 'fetch next 1 rows only' is for show only that 1 row. if you dont use 'fetch next 1 rows only' then it shows all the rows from the second row. </p>\n"}, {'answer_id': 45049174, 'author': 'Justine Jose', 'author_id': 2742464, 'author_profile': 'https://Stackoverflow.com/users/2742464', 'pm_score': 3, 'selected': False, 'text': '<p><strong>MSSQL</strong></p>\n\n<pre><code>SELECT  *\n  FROM [Users]\n    order by UserId desc OFFSET 1 ROW \nFETCH NEXT 1 ROW ONLY;\n</code></pre>\n\n<p><strong>MySQL</strong></p>\n\n<pre><code>SELECT  *\n  FROM Users\n    order by UserId desc LIMIT 1 OFFSET 1\n</code></pre>\n\n<p>No need of sub queries ... just skip one row and select second rows after order by descending</p>\n'}, {'answer_id': 46404204, 'author': 'Amit Prajapati', 'author_id': 5056304, 'author_profile': 'https://Stackoverflow.com/users/5056304', 'pm_score': 0, 'selected': False, 'text': '<pre><code> SELECT  * FROM `employee` WHERE  employee_salary = (SELECT employee_salary \n FROM`employee` GROUP BY employee_salary ORDER BY employee_salary DESC LIMIT \n 1,1)\n</code></pre>\n'}, {'answer_id': 46407836, 'author': 'rashedcs', 'author_id': 6714430, 'author_profile': 'https://Stackoverflow.com/users/6714430', 'pm_score': 1, 'selected': False, 'text': '<pre><code>select max(column_name) \nfrom table_name\nwhere column_name not in ( select max(column_name) \n                           from table_name\n                         );\n</code></pre>\n<p><strong>not in</strong> is a condition that exclude the  highest value of column_name.</p>\n<p>Reference : <a href="http://www.programmerinterview.com/index.php/database-sql/find-nth-highest-salary-sql/" rel="nofollow noreferrer">programmer interview</a></p>\n'}, {'answer_id': 48964594, 'author': 'Md. Nahidul Alam Chowdhury', 'author_id': 2149563, 'author_profile': 'https://Stackoverflow.com/users/2149563', 'pm_score': 0, 'selected': False, 'text': '<p>You can find nth highest value using the following query.</p>\n\n<pre><code>    select top 1 UnitPrice from (select distinct top n UnitPrice from \n[Order Details] order by UnitPrice desc) as Result order by UnitPrice asc\n</code></pre>\n\n<p>Here, the value of n will be 1 (for the highest number), 2 (for the second highest number), 3 (for the third highest number)...</p>\n'}, {'answer_id': 53327142, 'author': 'Md. Shamim Alam Javed', 'author_id': 6122642, 'author_profile': 'https://Stackoverflow.com/users/6122642', 'pm_score': 0, 'selected': False, 'text': '<p>At first make a dummy table without max salary then query max value from dummy table</p>\n\n<pre><code>SELECT max(salary) from (Select * FROM emp WHERE salary&lt;&gt; (SELECT MAX(salary) from emp)) temp\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/32100', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/184/']