【发布时间】:2013-03-25 00:05:12
【问题描述】:
我需要进行一个 sql 查询,它将显示以下内容:
'截至当前日期超过 90 天的活跃帐户总数'
日期来自一个 sql 查询,它是这样的:
select date from currentdatetable
现在我的查询是计算来自 accounttable 的所有活动帐户,因此我的查询如下所示:
select count(*) from accountstable
我的问题是如何声明 accounttable 中的日期比 currentdatetable 的日期早 90 天?
我当前的代码:
select count(*) from accountstable at where at.date > (select date from currentdatetable)
【问题讨论】:
-
你使用的是什么 rdbms?
-
微软 sql server 2005
-
只是好奇,为什么你有一个带有当前日期的表?而且里面只有一条记录吗?
-
它不是系统日期。日期取决于它所在的数据库
标签: sql sql-server-2005 date select count