有H2表:
CREATE TABLE IF NOT EXISTS sometable (ondate DATE NOT NULL);
有数据
INSERT INTO sometable VALUES ('2015-07-07');
INSERT INTO sometable VALUES ('2014-07-07');
INSERT INTO sometable VALUES ('2013-07-07');
我想限制选定的数据量,但以下选择不起作用。为什么?
SELECT YEAR(CONVERT(ondate, TIMESTAMP)) AS yr FROM sometable WHERE yr = 2015
错误消息是 SELECT YEAR(CONVERT(ondate, TIMESTAMP)) AS yr FROM sometable WHERE yr = 2015; 未找到“YR”列;SQL 语句:SELECT YEAR(CONVERT(ondate, TIMESTAMP)) AS yr FROM sometable WHERE yr = 2015 [42122-176] 42S22/42122