你正在運行到這裏的問題是,小時提取物的結果(見下文B1)返回一個整數,再減去從REQUEST_TIME被減去給人一種結果是天數你沒有想到或想要(見下面的C2)。
我相信,你所要找的東西需要將B1值轉換爲幾小時(見下面的D1)。
選擇REQUEST_TIME, TIMEZONE(CURRENT_TIMESTAMP, '美國/紐約', 'ETC/GMT') -
current_timestamp A1,
extract(hours from TIMEZONE(current_timestamp, 'America/New_York','Etc/GMT') - current_timestamp) B1,
request_time - extract(hours from TIMEZONE(current_timestamp, 'America/New_York','Etc/GMT') - current_timestamp) C1,
request_time - cast(extract(hours from TIMEZONE(current_timestamp, 'America/New_York','Etc/GMT') - current_timestamp) || ' hours ' as interval) D1
from table1;
TESTDB.ADMIN(ADMIN)-> from table1;
REQUEST_TIME | A1 | B1 | C1 | D1
---------------------+----------+----+------------+---------------------
2016-01-31 12:00:00 | 04:00:00 | 4 | 2016-01-27 | 2016-01-31 08:00:00
(1 row)
你提到你的問題,並在你的示例代碼使用子查詢,我但我沒有」在這種情況下,不需要再次選擇。
歡迎來到Stack Overflow! 。請編輯您的文章並進行格式化以提高可讀性。 – gmuraleekrishna