To get the 2 items; SELECT DISTINCT value FROM Table ORDER BY value DESC LIMIT 2 To get the second largest value of a column; SELECT MIN(value) FROM (SELECT DISTINCT value FROM Table ORDER BY value DESC LIMIT 2) AS t Please share i you know of any other better way.
Posts Tagged ‘MySQL’
Mysql – Finding second highest value of a column in a table.
Posted in MySQL, tagged MySQL on October 20, 2011 | Leave a Comment »
Mysql – Calculate sum of distinct Rows
Posted in MySQL, tagged MySQL on October 3, 2011 | Leave a Comment »
We can use “DISTINCT” keyword with ‘count’ to acheive this; select index, count(DISTINCT number) from <table> group by index;
How mysql index works?
Posted in MySQL, tagged MySQL on September 26, 2011 | Leave a Comment »
The index makes query execution(where, order) faster because it is stored in memory, the corresponding index row can be looked at and it contains a pointer to where the actual data is stored. So MySQL can go to the exact location in the table without having to scan the table Basically an index is a [...]
When to use Indexes In MySQL
Posted in MySQL, tagged MySQL on September 26, 2011 | Leave a Comment »
Indexes are best used on columns that are frequently used in where clauses, and in any kind of sorting, such as “order by”. You should also pay attention to whether or not this information will change frequently, because it will slow down your updates and inserts. Since you wont frequently be adding employees, you don’t [...]
[Windows] Starting MySQL from the Windows Command Line
Posted in installations, MySQL, tagged installations, MySQL on August 20, 2011 | Leave a Comment »
The MySQL server can be started manually from the command line. This can be done on any version of Windows. To start the mysqld server from the command line, you should start a console window (or “DOS window”) and enter this command: shell> “C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqld” The path to mysqld may vary depending on [...]
The procedure entry point mysql_stmt_row_tell could not be located in the dynamic link library LIBMYSQL.dll
Posted in Weird Errors, tagged bug fixes, lessons, MySQL, Ruby on Rails on November 25, 2008 | Leave a Comment »
If you are getting the following error, here is a quick fix that will get you working again. You will need to manually copy the libmysql.dll to the rubybin directory. Search for libmysql.dll file and copy it to the rubybin folder and
The dynamic link library LIBMYSQL.dll could not be found in the specified path
Posted in Ruby on Rails, Weird Errors, tagged MySQL, Ruby on Rails, tips, windows on November 25, 2008 | Leave a Comment »
When you find this error alert in windows, make sure you do one of the following; Find the LIBMYSQL.dll file and add its location to the PATH(environment-variable) (or) copy LIBMYSQL.dll to the System32 directory.