Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.
This repository was archived by the owner on Oct 17, 2025. It is now read-only.

crosstab example #61

@joshRpowell

Description

@joshRpowell

I've got a number of basic queries working and found the gem to be quite useful.

However, I have the following crosstab query:

class OverflowPivotReport < Dossier::Report
  def sql
    '
    SELECT * FROM crosstab('
        SELECT zip, status, status_count
        FROM "status_counts"
        ORDER BY 1, 2;')
    AS ct (zip character varying, "0" bigint, "1" bigint, "2" bigint, "8" bigint);
    '
  end
end

status_counts is a DB view.
when I run the query directly on the DB it works fine.

I get the following error when I run the .html report:

undefined local variable or method `zip' for #<OverflowPivotReport:0x007fc2dd1cacd0>

I saw the following in the documentation:

Show how to do "crosstab" reports (preliminary query to determine columns, then build SQL case statements?)

Not sure where to go from here...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions