【发布时间】:2016-08-13 18:12:14
【问题描述】:
我怎样才能在 where 子句中为这样的事情返回值:
获取table1.de1,table2.de2,table3.de3,table4.de3中存在的所有记录
select *
from table1
inner join table2
on table2.carID = table1.carID
inner join table3
on table3.carID = table1.carID
inner join table4
on table4.driverID = table1.driverID
recietrecord 存在于 table2 中,其 paydate 已过去 20 天,将其与 TODAYS 日期进行比较,并在名为 Days Passed From The Day Driver Was Suppose To Pay 的字段中显示这些日子
【问题讨论】:
-
您可以在选择子句中使用
DateDiff(dd, paydate, getdate())来显示日期差异。在 where 子句中,你可以有一个 whereDateDiff(dd, paydate, getdate()) < 0或适当的东西
标签: sql-server join