MS Access 查询问题?

发布于 2024-10-23 21:30:52 字数 1241 浏览 0 评论 0原文

我正在使用此查询:

SELECT D.Generic, D.Ww, D.Dd, D.Plan, c.TotalScan, D.Plan - c.TotalScan AS Balance
  FROM TableA D
       LEFT JOIN (
                  SELECT COUNT(a.Specific) AS TotalScan,
                         b.Generic, a.Dd,a.Ww  
                    FROM TableB a 
                         INNER JOIN TableC b 
                            ON a.Specific = b.Specific
                   GROUP 
                      BY b.Generic,a.Dd,a.Ww 
                   WHERE DATEDIFF(DAY, a.TransactionDate, GETDATE()) = 0
                 ) c
          ON c.Generic = D.Generic 
             AND D.Ww = c.Ww 
             AND c.Dd = D.Dd
 WHERE DATEDIFF(DAY, c.TransactionDate, GETDATE()) = 0;

过滤在我的 sqlserver 数据库中插入的所有记录。

现在我很难做到MS访问。

1. DATEDIFF(Day, TransactionDate, GetDate()) = 0  -- Not Work on MS Access(Which Filter all Records inserted in current Date) 
2. Cant display TotalScan from subquery

输出日期示例:

TransactionDate
3/21/2011 7:26:24 AM
3/21/2011 7:26:24 AM
3/22/2011 7:26:24 AM --
3/22/2011 7:26:28 AM --
3/22/2011 7:26:30 AM --
3/22/2011 7:26:32 AM --
3/22/2011 7:26:35 AM --

如果我今天的日期是 3/22/2011,将显示 5 条记录。

谢谢问候

I am using this query:

SELECT D.Generic, D.Ww, D.Dd, D.Plan, c.TotalScan, D.Plan - c.TotalScan AS Balance
  FROM TableA D
       LEFT JOIN (
                  SELECT COUNT(a.Specific) AS TotalScan,
                         b.Generic, a.Dd,a.Ww  
                    FROM TableB a 
                         INNER JOIN TableC b 
                            ON a.Specific = b.Specific
                   GROUP 
                      BY b.Generic,a.Dd,a.Ww 
                   WHERE DATEDIFF(DAY, a.TransactionDate, GETDATE()) = 0
                 ) c
          ON c.Generic = D.Generic 
             AND D.Ww = c.Ww 
             AND c.Dd = D.Dd
 WHERE DATEDIFF(DAY, c.TransactionDate, GETDATE()) = 0;

to filter all records that is a insert in my sqlserver database.

Now i am having a hard time how can i do it ms access.

1. DATEDIFF(Day, TransactionDate, GetDate()) = 0  -- Not Work on MS Access(Which Filter all Records inserted in current Date) 
2. Cant display TotalScan from subquery

Example Output Date:

TransactionDate
3/21/2011 7:26:24 AM
3/21/2011 7:26:24 AM
3/22/2011 7:26:24 AM --
3/22/2011 7:26:28 AM --
3/22/2011 7:26:30 AM --
3/22/2011 7:26:32 AM --
3/22/2011 7:26:35 AM --

if my date today is 3/22/2011 5 records will be displayed.

Thanks in Regards

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我偏爱纯白色 2024-10-30 21:30:52

GetDate() 是 SQL Server 特定的,Access 有 Now()

Access 中也存在 DateDiff() 函数,但间隔的参数不同:

DateDiff("d", TransactionDate, Now())

GetDate() is SQL Server specific, Access has Now() instead.

The DateDiff() function also exists in Access, but the parameter for the interval is different:

DateDiff("d", TransactionDate, Now())
夜唯美灬不弃 2024-10-30 21:30:52

相当于:

DATEDIFF(DAY, c.TransactionDate, GETDATE()) = 0

DATEDIFF("d", c.TransactionDate, Now()) = 0 

问候

Equivalent of:

DATEDIFF(DAY, c.TransactionDate, GETDATE()) = 0

DATEDIFF("d", c.TransactionDate, Now()) = 0 

Regards

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文