時間:2024-03-12 20:33作者:下載吧人氣:21
比如氣象臺的氣溫監控,每半小時上報一條數據,有很多個地方的氣溫監控,這樣數據表里就會有很多地方的不同時間的氣溫數據
每次查詢只查最新的氣溫數據按照不同的溫度區間來分組查出,比如:高溫有多少地方,正常有多少地方,低溫有多少地方
3.1 創建表結構:
— DROP TABLE public.t_temperature
CREATE TABLE public.t_temperature (
id int4 NOT NULL GENERATED ALWAYS AS IDENTITY,
place_name varchar NOT NULL,
value float8 NOT NULL,
up_time timestamp NOT NULL,
CONSTRAINT t_temperature_pk PRIMARY KEY (id)
);
— Permissions
ALTER TABLE public.t_temperature OWNER TO postgres;
GRANT ALL ON TABLE public.t_temperature TO postgres;
網友評論