我的:
<!--查询小于指定日期的第几个记录--> <select id="beforeDateNumPrice" resultType="com.mytrade.data.entity.TxdData"> SELECT b.trade_date, b.start_price, b.max_price, b.end_price, b.turnover, b.variety_code, b.variety_name, b.id FROM ( SELECT @rowno :=@rowno + 1 AS rowno, a.* FROM ( SELECT * FROM txd_data r WHERE r.trade_date < #{tradeDate} ORDER BY trade_date DESC ) a, (SELECT @rowno := 0) t ) b WHERE b.rowno = #{beforeNum}; </select>
mapper类:
TxdData beforeDateNumPrice(@Param("tradeDate")Date tradeDate, @Param("beforeNum")Integer beforeNum);
参考:
转: