将MS Access sql语句转换为MS SQL语句

时间:2019-02-20 15:38:37

标签: sql-server

此MS Access sql语句到MS SQL语句的转换是什么

Select * 
from iapt 
where appt_id in (Select distinct appt_id 
                  from iaptd where po_id in(Select distinct po_id 
                                            from irct 
                                            where verify_dtim = Date()-1))

2 个答案:

答案 0 :(得分:1)

我想您只需要更改

Date() - 1

DATEADD(dd, -1, CAST(GETDATE() AS DATE))

答案 1 :(得分:1)

GETDATE()(今天)开始减去一天。

Select * 
from iapt 
where appt_id in (Select distinct appt_id 
from iaptd where po_id in(Select distinct po_id 
from irct 
where verify_dtim = DATEADD(day, -1, convert(date, GETDATE())))