在POSTGRESQL中DATE PBM

时间:2015-03-18 04:23:51

标签: sql postgresql grails

SELECT SUM(salesamt) from t0006.retailsummary WHERE perioddate between '2012-11-2' and '2013-12-31';

它的作品,但我想(使用日期变量,我指定了startdate=2012-11-1

SELECT SUM(salesamt) from t0006.retailsummary WHERE perioddate between startdate and enddate;

它不起作用

1 个答案:

答案 0 :(得分:0)

\set startdate '\'' 2012-11-02 '\''
\set enddate '\'' 2013-12-31 '\''
SELECT SUM(salesamt) from t0006.retailsummary WHERE perioddate between :startdate and :enddate;