[PATCH] Add native PIVOT syntax for SQL Server/Oracle compatibility - Mailing list pgsql-hackers

From Myles Lewis
Subject [PATCH] Add native PIVOT syntax for SQL Server/Oracle compatibility
Date
Msg-id 5D71B366-0C2D-4BD9-B197-93851A86B1C1@sbcglobal.net
Whole thread Raw
List pgsql-hackers
I've developed a patch that adds native PIVOT syntax to PostgreSQL,
enabling SQL Server and Oracle-style pivot queries.

Example:
  SELECT region
  FROM sales
  PIVOT (SUM(revenue) FOR quarter IN ('Q1', 'Q2', 'Q3', 'Q4'));

Key features:
- Parser-level transformation to FILTER aggregates
- No executor changes required
- Supports SUM, COUNT, AVG, MIN, MAX
- View creation with pg_get_viewdef() roundtrip
- Comprehensive regression tests (788 lines)

Patch attached.

Myles
Attachment

pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Re: [Proposal] Adding TRIM_SPACE option to COPY
Next
From: Tom Lane
Date:
Subject: Re: [Proposal] Adding TRIM_SPACE option to COPY