您的位置:首页 > 数据库

SQL 语句优化 案例1

2009-09-29 09:26 274 查看
select count(1)
2 into l_line_num --l_number_of_day
3 from hek_om_pop_validity_all
4 where inventory_item_id = l_item_id
5 and ((start_date <= sysdate
6 and end_date >= sysdate)
7 or (start_date <= sysdate and end_date is null));
修改后:

select count(1)
2 into l_line_num --l_number_of_day
3 from hek_om_pop_validity_all
4 where inventory_item_id = l_item_id
5 and start_date <= sysdate
6 and nvl(end_date, sysdate + 1) >= sysdate;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: