查询选择时间的前一天的最大时间的记录信息?
原sql语句:
方法一:
SELECT b.BDHSL FROM w_pckcbd b WHERE a.pc_id = b.pc_id
AND b.AAE036 = (
SELECT c.AAE036 FROM w_pckcbd c
WHERE c.AAE036 < '2017-05-09 00:00:00' ORDER BY c.AAE036 DESC LIMIT 0,1
)
方法二:
SELECT b.BDHSL FROM w_pckcbd b WHERE a.pc_id = b.pc_id
AND b.AAE036 = (
SELECT MAX(c.AAE036) FROM w_pckcbd c
WHERE c.AAE036 < '2017-05-09 00:00:00'
)
改进sql语句:
SELECT b.BDHSL FROM w_pckcbd b WHERE a.pc_id = b.pc_id
AND b.aae036 < '2017-05-09 00:00:00' ORDER BY b.AAE036 DESC LIMIT 0,1
一个sql查询语句(记录学习的点滴)
最新推荐文章于 2023-10-06 17:37:27 发布