title: MS Access last() results are sometimes wrong
body: <p>I have an MS Access query that uses last() but sometimes it doesn't work as expected--which I know is what's expected lol.  But I need to find a solution, either in Access or by converting the below query to MySQL.  Any suggestions?</p>
  
  <pre><code>SELECT maindata.TrendShort, Last(maindata.Resistance) AS LastOfResistance, Last(maindata.Support) AS LastOfSupport, Count(maindata.ID) AS Days, Max(maindata.Datestamp) AS Datestamp, maindata.ProductID
  FROM market_opinion AS maindata
  WHERE (((Exists (select * from market_opinion action_count where maindata.ProductID = action_count.ProductID  and maindata.Datestamp &lt; action_count.Datestamp and maindata.TrendShort&lt;&gt; action_count.TrendShort))=False))
  GROUP BY maindata.TrendShort, maindata.ProductID
  ORDER BY Count(maindata.ID) DESC;
  </code></pre>
  
  <p>Only the LastOfResistence and LastOfSupport are occasionally wrong, the other fields are always correct.</p>
  
  <pre><code>CREATE TABLE `market_opinion` (
    `ID` int(11) NOT NULL AUTO_INCREMENT,
    `ProductID` int(11) DEFAULT NULL,
    `Trend` varchar(11) DEFAULT NULL,
    `TrendShort` varchar(7) DEFAULT NULL,
    `Resistance` decimal(9,2) unsigned DEFAULT NULL,
    `Support` decimal(9,2) unsigned DEFAULT NULL,
    `Username` varchar(12) DEFAULT NULL,
    `Datestamp` date DEFAULT NULL,
    PRIMARY KEY (`ID`),
    KEY `ProductID` (`ProductID`),
    KEY `Datestamp` (`Datestamp`),
    KEY `TrendShort` (`TrendShort`)
  ) ENGINE=InnoDB AUTO_INCREMENT=9536 DEFAULT CHARSET=utf8;
  </code></pre>