有下表:
create table operations
(
operation varchar,
date_time timestamp default now(),
id serial
constraint operations_pk
primary key,
value numeric(9,2)
);
operation 是一个可以取值 orig(this is +) 或 stor(this is -(minus)) 的字段。
value - 要计算的实际值 (111.00, 1231231.34)。
date_time - 时间(今天的所有值都应该考虑在内)。
这将如何在请求级别组织?提前致谢)
例如,您可以使用 case 语句:
这导致操作值为负,为
operation = 'stor'正orig,其余为 NULL。此外,该表达式可用于根据任务对功能进行分组。例如,
它看起来像一个普通
CASE的,不是吗?