我有这样的表:
CREATE TABLE public."Payments"
(
user_id integer,
"1 month later" numeric(19,4),
"2 months later" numeric(19,4),
"3 months later" numeric(19,4),
"4 months later" numeric(19,4),
"5 months later" numeric(19,4),
"6 months later" numeric(19,4),
"7 months later" numeric(19,4),
"8 months later" numeric(19,4),
"9 months later" numeric(19,4),
"10 months later" numeric(19,4),
"11 months later" numeric(19,4),
"12 months later" numeric(19,4)
例如,里面有这样的数据:
INSERT INTO "Payments" ("user_id", "1 month later", "2 months later", "3 months later", "4 months later", "5 months later", "6 months later", "7 months later", "8 months later", "9 months later", "10 months later", "11 months later", "12 months later") VALUES (134329, 190, 190, 190, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
我需要为每个用户 ID 获取总和,其中有很多。postgres 中是否有任何可以快速完成的功能?