I have created my first MySQL query to get the minimum LTP by MarketName/SelectionName. It works ok but I’m struggling to work out how to get the rest of the fields from the original table (checktable).
I just want the records containing with the minimum LTP.
Can anyone point me in the right direction?
Thanks
SELECT MarketName, SelectionName, MIN(LTP) AS LTP
FROM checktable
WHERE MarketState = "Not In Play" AND SelectionID <> 0 AND CloseTime <> "" AND Result <> ""
GROUP BY MarketName, SelectionName HAVING COUNT(*) > 900
2
Answers
Use window functions
ROW_NUMBER()
andCOUNT()
:You can use your query result to select from the tabe again in order to get the complete rows: