小编Mos*_*atz的帖子

同时聚合计数和完整计数

我有一个events这样的表:

create table events
(
    correlation_id char(26) not null,
    user_id        bigint,
    task_id        bigint not null,
    location_id    bigint,
    type           bigint not null,
    created_at     timestamp(6) with time zone not null,
    constraint events_correlation_id_created_at_user_id_unique
        unique (correlation_id, created_at, user_id)
);
Run Code Online (Sandbox Code Playgroud)
CREATE TABLE
Run Code Online (Sandbox Code Playgroud)

该表保存正在执行的任务的记录,如下所示:

insert into events (correlation_id, user_id, task_id, location_id, type, created_at)
values  ('01CN4HP4AN0000000000000001', 4, 58, 30, 0, '2018-08-17 18:17:15.348629+00'),
        ('01CN4HP4AN0000000000000001', 4, 58, 30, 1, '2018-08-17 18:17:22.852299+00'),
        ('01CN4HP4AN0000000000000001', 4, 58, 30, 99, '2018-08-17 18:17:25.535593+00'),
        ('01CN4J9SZ80000000000000003', 4, 97, 30, 0, '2018-08-17 18:28:00.104093+00'),
        ('01CN4J9SZ80000000000000003', 4, …
Run Code Online (Sandbox Code Playgroud)

postgresql aggregate count

5
推荐指数
1
解决办法
291
查看次数

标签 统计

aggregate ×1

count ×1

postgresql ×1