Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
(1)select * from bdorder
(2) select * from bdorder
order by orderdate desc
前者执行为15% 而后者要85% 差了5倍多!
故在用DESC 要慎用,效率太低!
典型应用:
左连接取出连接表符合条件的第一条记录
left? join bdship d(NOLOCK)
on d.orderno = c.orderno
AND d.id=(select top 1 id from bdship m where m.orderno = d.orderno order by id desc )
应改为:
left? join bdship d(NOLOCK)
on d.orderno = c.orderno
AND d.shipdate=(select max(shipdate) from bdship m where m.orderno = d.orderno? )