查找过去三天内发布的所有广告的ID,即Sql

时间:2013-02-09 07:20:20

标签: sql oracle

我是SQL新手。我有一张表格,其中包含有关广告的信息。我应该使用哪个功能来查找过去三天内发布的所有广告的ID?

2 个答案:

答案 0 :(得分:1)

Select ID --the id field
From tblAds --the ads table
WHERE Ad_Date >= DATEADD(day,-3,getDate()) --the filter. I am assuming Ad-Date is the name of the ad's date field
order by Ad_Date ASC -- order it

答案 1 :(得分:1)

对于Oracle DB,请使用此

SELECT id
FROM tablename
WHERE TRUNC(pdate) >= TRUNC(SYSDATE) - 3;

<强> SQLFIDDLE DEMO