I have a series of observations of which one column is sometimes missing (zero):
date temp delta
1977 284.54 29.84
1978 149.82 0
1979 320.71 28.45
1980 176.76 0
1981 854.65 0
1984 817.65 0
1985 990.58 27.98
1986 410.21 0
1987 405.93 0
1988 482.9 0
What I would like to achieve is a SQL selection whereby the non-zero values are copied down, in other words, to achieve the following:
date temp delta
1977 284.54 29.84
1978 149.82 29.84
1979 320.71 28.45
1980 176.76 28.45
1981 854.65 28.45
1984 817.65 28.45
1985 990.58 27.98
1986 410.21 27.98
1987 405.93 27.98
1988 482.9 27.98
Is there a standard way to achieve this without having to resort to creating a procedural SQL script?
DROP TABLE IF EXISTS `temperatures`;
CREATE TABLE `temperatures` (
`date` integer,
`temp` double,
`delta` double
) ENGINE=MyISAM;
INSERT INTO `temperatures` VALUES (1977,284.54,29.84), (1978,149.82,''),
(1979,320.71,28.45), (1980,176.76,''), (1981,854.65,''),
(1984,817.65,''), (1985,990.58,27.98), (1986,410.21,''),
(1987,405.93,''), (1988,482.9,''), (1991,269.02,'');