---说明:在表article_detail中,article_detail_id是主键,extracted_time默认是sysdate,且建了索引,下面二条语句的查询结果相同,第二条的执行效率高些
--1.各网站最后一条记录入库时间(效率低)
select website_no, max(extracted_time) as Last_extracted_time from article_detail where
website_no in
('FM37','FM38','FM39','FM41','FM42','FM43','FM44','FM45','FM46',
'FM48','FM49','FM50','FM51','FM52','FM107','FM108','FM109','FM110','FM111','FM112','FM121',
'NW35','NW36','NW37','NW38','NW39','NW40','NW41','NW42','NW43',
'BG9','BG10','BG11','BG12'
)
group by website_no order by website_no;
--2.各网站最后一条记录入库时间(效率较高)
select website_no,extracted_time as Last_extracted_time from article_detail where article_detail_id in
(
select max(article_detail_id) as article_detail_id from article_detail where
website_no in ('FM37','FM38','FM39','FM41','FM42','FM43','FM44','FM45','FM46',
'FM48','FM49','FM50','FM51','FM52','FM107','FM108','FM109','FM110','FM111','FM112','FM121',
'NW35','NW36','NW37','NW38','NW39','NW40','NW41','NW42','NW43',
'BG9','BG10','BG11','BG12'
)group by website_no
)
order by website_no;
--1.各网站最后一条记录入库时间(效率低)
select website_no, max(extracted_time) as Last_extracted_time from article_detail where
website_no in
('FM37','FM38','FM39','FM41','FM42','FM43','FM44','FM45','FM46',
'FM48','FM49','FM50','FM51','FM52','FM107','FM108','FM109','FM110','FM111','FM112','FM121',
'NW35','NW36','NW37','NW38','NW39','NW40','NW41','NW42','NW43',
'BG9','BG10','BG11','BG12'
)
group by website_no order by website_no;
--2.各网站最后一条记录入库时间(效率较高)
select website_no,extracted_time as Last_extracted_time from article_detail where article_detail_id in
(
select max(article_detail_id) as article_detail_id from article_detail where
website_no in ('FM37','FM38','FM39','FM41','FM42','FM43','FM44','FM45','FM46',
'FM48','FM49','FM50','FM51','FM52','FM107','FM108','FM109','FM110','FM111','FM112','FM121',
'NW35','NW36','NW37','NW38','NW39','NW40','NW41','NW42','NW43',
'BG9','BG10','BG11','BG12'
)group by website_no
)
order by website_no;