1

次のクエリを実行できます

select (current_date-interval '1' day) ,a,b from (select '1' as a, 2 as b) as t2;

しかし、「1」の代わりに変数を配置することはできません。次の方法を試しましたが成功しませんでした

select (current_date-interval b day) ,a,b from (select '1' as a, 2 as b) as t2;
select (current_date-interval a day) ,a,b from (select '1' as a, 2 as b) as t2;

私もキャストを試みましたが、まだ結果はありません。

4

1 に答える 1

1

私はこれに対する解決策を見つけました:

select (current_date-interval 1 day*b) ,a,b from (select '1' as a, 2 as b) as t2;
select (current_date-interval 1 day*cast(a as int)) ,a,b from (select '1' as a, 2 as b) as t2;

したがって、この質問は答えられます:)

于 2013-04-29T07:40:09.587 に答える