我有以下查询。但是TranDate,Amount,Balance显示为Null。是Postgresql的新手。但是在SQL Server中显示的值
CREATE TEMP TABLE tran
(TranDate,Amount,Balance) AS
VALUES
('2019-01-01'::date, 1000::int,1000::int),
('2019-01-02', 2000,3000),
('2019-01-03', NULL,3000),
('2019-01-04', -500,2500);
SELECT tran.TranDate,tran.Amount,tran.Balance, date(d) as day
FROM generate_series(timestamp '2018-01-01'
, timestamp '2018-01-31'
, interval '1 day') d
left join tran ON date(tran.TranDate) = d
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句