【发布时间】:2014-10-22 20:26:00
【问题描述】:
我是 SQL 新手,一直在寻找一种在 ANSI SQL 中设置变量的方法。我有这个:
select * from table1
where first_date > '2014-01-01'
and where second_date = '2014-01-01'
and where third_date < '2014-01-01'
但我希望得到类似的东西:
set x = '2010-12-31'
select * from table1
where first_date > x
and where second_date = x
and where third_date < x
我阅读了有关存储过程的信息,但对于看似简单的事情来说,这似乎有点矫枉过正。我在 Netezza 上运行,但我想要一个也可以在其他数据库上运行的通用解决方案。
【问题讨论】: