Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我只是 sql server 查询的新手。我有一个名为到期的列。我想过滤当月内的截止日期数据。
SELECT * FROM TABLE1 WHERE duedate = within current month only
提前致谢。
您应该使用范围查询而不是将列包装在函数调用中,以便可以使用索引。
SELECT * FROM TABLE1 WHERE duedate >= DATEADD(month, DATEDIFF(month, 0, getdate()), 0) AND duedate < DATEADD(month, 1 + DATEDIFF(month, 0, getdate()), 0)