Sha256: 194186df3bb0d6ed5e5ce14400c0b72d12668d197cd203b3db47f64bcada1a9c

Contents?: true

Size: 513 Bytes

Versions: 16

Compression:

Stored size: 513 Bytes

Contents

CREATE OR REPLACE VIEW message_store.type_summary AS
  WITH
    type_count AS (
      SELECT
        type,
        COUNT(id) AS message_count
      FROM
        message_store.messages
      GROUP BY
        type
    ),

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

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

Version data entries

16 entries across 16 versions & 1 rubygems

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