0
我有一個表startdate
和enddate
。如何在postgresql的情況下得到一個新的列
其中開始日期大於endate我需要計算總天數爲30否則(enddate - startdate)+1 ...我如何爲它創建一個case語句。
Select case when 'startdate > enddate' then 30
when 'startdate > enddate' then (fine_fatturazione - startdate)+1
end
as td from table1
startdate enddate
04-10-2015 04-12-2015
10-07-2015 09-08-2015
05-12-2015 04-01-2016
07-02-2016 04-01-2016
你有沒有從表中的樣本,你希望有結果的一個例子嗎? – mongotop
'當'startdate> enddate''無效時。 ''startdate> enddate''是一個字符串常量,但'when'子句需要一個布爾值。你需要使用'when startdate> enddate'(沒有單引號) –