Skip to content

SQLPage cannot parse sql statement using posgresql crosstab function #690

Closed Answered by lovasoa
lozdown asked this question in Q&A
Discussion options

You must be logged in to vote

Here is a solution using the dynamic component, that should be more easily portable across databases, and probably a little bit more performant too. It also avoids having to specify all date names in the query:

WITH filled_data AS (
  SELECT
    m."Last Name",
    m."First Name",
    e.eventdate,
    EXISTS(
        SELECT 1
        FROM events_members em
        WHERE em.events_id = e.id AND
              em."members_Contact ID" = m."Contact ID"
    ) AS participation
  FROM members m
  CROSS JOIN events e
)
SELECT 
    'dynamic' AS component,
    jsonb_build_object('Name', "Last Name" || ', ' || "First Name") ||
    jsonb_object_agg(
        eventdate,
        CASE WHEN participation THEN 

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by lozdown
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants