sql - sql查询不包括当前日期的数据
问题描述
嗨,我想选择不包括当前日期的最近 3 天数据。
我在雪花上尝试类似下面的东西。
select * from Table where S_date <= DATEADD(DAY, -3, current_date-1) .
但它也包括当前日期。
请帮忙。
解决方案
在标准 SQL 中,语法为:
where S_date >= current_date - interval '3 day' and
S_date < current_date
这适用于某些数据库。但数据库通常有自己的日期/时间函数,因此可能需要针对您的数据库定制语法。
在雪花中:
where S_date >= dateadd(day, -3, current_date) and
S_date < current_date
推荐阅读
- typescript - 如何将 TypeScript 文件的对象文字 AST 转换为实际代码?
- android - android中的getwindow()不清除以前的图像
- uwp - 如何在 CanvasGeometry 上添加效果
- angular - Angular 6 - 如何在 IF 条件下更改其模板中的组件值
- file-io - 在 Julia 1.0.0 中将大数字输出保存到本地文件
- html - 悬停一个元素以更改另一个不是子元素或兄弟元素的元素
- javascript - 如何使用 JavaScript 制作分秒的倒数计时器?
- node.js - 如何使用 NodeJS SDK for IBM Cloud Object Storage 生成预签名链接?
- delphi - Delphi 10.2 中未设置编译器指令
- javascript - 为什么以下 JS 代码不会在浏览器中终止?