Sha256: 4dd9ac8bf3ef68fb407c8999022fcb47a94baf710a064411a49002c2ef40c26a

Contents?: true

Size: 547 Bytes

Versions: 16

Compression:

Stored size: 547 Bytes

Contents

CREATE OR REPLACE VIEW message_store.stream_summary AS
  WITH
    stream_count AS (
      SELECT
        stream_name,
        COUNT(id) AS message_count
      FROM
        message_store.messages
      GROUP BY
        stream_name
    ),

    total_count AS (
      SELECT
        COUNT(id)::decimal AS total_count
      FROM
        message_store.messages
    )

  SELECT
    stream_name,
    message_count,
    ROUND((message_count / total_count)::decimal * 100, 2) AS percent
  FROM
    stream_count,
    total_count
  ORDER BY
    stream_name;

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
message-db-3.0.0 database/views/stream-summary.sql
message-db-2.1.6 database/views/stream-summary.sql
message-db-2.1.5 database/views/stream-summary.sql
message-db-2.1.4 database/views/stream-summary.sql
message-db-2.1.3 database/views/stream-summary.sql
message-db-2.1.2 database/views/stream-summary.sql
message-db-2.1.1 database/views/stream-summary.sql
message-db-2.1.0 database/views/stream-summary.sql
message-db-2.0.2 database/views/stream-summary.sql
message-db-2.0.1 database/views/stream-summary.sql
message-db-2.0.0 database/views/stream-summary.sql
message-db-1.1.3 database/views/stream-summary.sql
message-db-1.1.2 database/views/stream-summary.sql
message-db-1.1.1 database/views/stream-summary.sql
message-db-1.1.0 database/views/stream-summary.sql
message-db-1.0.0 database/views/stream-summary.sql