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.
我收到一个要求,我必须从数据库中选择 3 个日期,但我的表记录的日期时间字段不按顺序排列。如何编写SQL以获得比今天多 3 个日期的记录?
谢谢
我认为这就是你所需要的。只需用于GETDATE()获取当前日期。
GETDATE()
SELECT TOP 3 dateColumn from myTable where dateColumn > GETDATE()
Select top 3 * from <tablename> where yourdateColumn > getdate() order by desc