我有下表:
CREATE TABLE trans (
id SERIAL PRIMARY KEY,
trans_date date,
trans_time time
);
Run Code Online (Sandbox Code Playgroud)
我想有以下观点
CREATE OR REPLACE VIEW daily_trans AS
SELECT trans_date,
max(trans_time) as first,
min(trans_time) as last,
calculate_status(min(trans_time), max(trans_time)) as status
GROUP BY trans_date
Run Code Online (Sandbox Code Playgroud)
带有指定最大和最小 trans_time id 的列。
我怎么做?