 <p>You are using an aggregate function <code>max</code> with out providing a grouping criteria so your table prices will be treated as one group and the results of query will be returned in indeterminate order means it will give you the max value for your criteria but it will not guarantee you to give the relevant date which has the max value so your second query can be written as</p> <pre><code>select ((close-open)/open) as daychange, date from prices order by daychange desc limit 1 ; </code></pre> <p>So the above query will calculate daychange for each row and it will sort the result by daychange values in descending order and limiting to 1 will give you the max value for your criteria and the relevant data value too</p>