MySQL -> Select second lowest value

2015-01-14T19:26:50

I'm currently using min() to find the lowest value within MYSQL database.

How could i find the second lowest value?

'select Date, Horse, ParentID, min(odds2) 
from horsesrp 
where odds2 < 3.1 and odds2 > 1.9 
and Date = "'.$id.'" 
AND Track IN ("Kempton (AW)","Wolverhampton (AW)") 
group by ParentID order by ParentID'

please note i still need to order by ParentID as i want to get the second lowest odds2 per parentid

so my database look like:

Racetime Odds

13:05     2
13:05     2.4
13:05     3
13:05     5
13:30     3
13:30     5
13:30     9
13:30     13.5
14:00     1.14
14:00     1.19
14:00     2
14:00     4

i want to find the second lowest value for each time but it must be between 1 and 2.9

Racetime Odds

13:05     2.4
14:00     1.19

so the output for the above would be

Thanks

Emma

Copyright License:
Author:「emma perkins」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/27941820/mysql-select-second-lowest-value

About “MySQL -> Select second lowest value” questions

I have MySQL on a system, and I am trying to determine if it is Oracle MySQL, or MySQL. Is there a difference between Oracle MySQL: http://www.oracle.com/us/products/mysql/index.html and "regular"
I finally install mysql cluster on two servers and got them running: [ndbd(NDB)] 2 node(s) id=2 @xx.xx.xx.xxx (mysql-5.6.25 ndb-7.4.7, Nodegroup: 0, *) id=3 @yy.yyy.yyy.yyy (mysql-5.6.25 n...
I know the question I am about to ask is a very stupid once but I am new to MYSQL so please bear with me. Want I want to do is create a database on my local machine and also access/manipulate it from
I want to use MySQL server on two different ports on the same machine. I have made two separate config files. When I'm trying to connect to the MySQL server on the second port I defined then I can't
We have a batch processing script that performs somewhat these operations fetch data from the WHMCS database for each rows; if rows needs processing connect to data's specified external MySQL dat...
I have made some shitty things to MySQL and I facing this. I am trying to re-install MySQL. directly deleted the MySQL folder using sudo rights and tried to re-install. the fix will be greatly
I just updated my MySQL 5.7 database to MySQL 8.0 The MySQL documentation says : The MySQL server always restarts after an update by APT. Prior to MySQL 8.0.16, run mysql_upgrade after the se...
I'm looking at implementing a failover mechanism for a MySQL database using MySQL Proxy (http://forge.mysql.com/wiki/MySQL_Proxy) My proposed setup is as follows: One active MySQL server and one p...
The path to my bin folder with mysql: usr/local/mysql/bin Here is my zshrc bash config: export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/mysql/bin:/Users/leon/bin/subl" ex...
I have installed MySQL on WSL2 with the following $ sudo apt remove --purge *mysql* $ sudo rm -rf /var/lib/mysql $ sudo apt install -y mysql-server mysql-client invoke-rc.d: could not determine cu...

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.