File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -4551,12 +4551,21 @@ match_recognize
45514551 ;
45524552
45534553pivot_unpivot
4554- : PIVOT LR_BRACKET id_ LR_BRACKET id_ RR_BRACKET FOR id_ IN LR_BRACKET literal (COMMA literal)* RR_BRACKET RR_BRACKET (
4555- as_alias column_alias_list_in_brackets?
4556- )?
4554+ : PIVOT LR_BRACKET id_ LR_BRACKET id_ RR_BRACKET FOR id_ IN LR_BRACKET pivot_in_clause RR_BRACKET default_on_null? RR_BRACKET (
4555+ as_alias column_alias_list_in_brackets? )?
45574556 | UNPIVOT LR_BRACKET id_ FOR column_name IN LR_BRACKET column_list RR_BRACKET RR_BRACKET
45584557 ;
45594558
4559+ pivot_in_clause
4560+ : literal (COMMA literal)*
4561+ | ANY order_by_clause?
4562+ | subquery
4563+ ;
4564+
4565+ default_on_null
4566+ : DEFAULT ON NULL_ (expr)
4567+ ;
4568+
45604569column_alias_list_in_brackets
45614570 : LR_BRACKET id_ (COMMA id_)* RR_BRACKET
45624571 ;
Original file line number Diff line number Diff line change @@ -155,4 +155,14 @@ show warehouses
155155SELECT 0 as c
156156- >> SELECT c FROM $1
157157- >> SELECT c FROM $2
158- - >> SELECT c FROM $3 ;
158+ - >> SELECT c FROM $3 ;
159+
160+ SELECT * FROM t PIVOT(SUM (amount) FOR quarter IN (ANY ORDER BY c1 desc )) ORDER BY empid;
161+ SELECT * FROM t PIVOT(SUM (amount) FOR quarter IN (ANY));
162+ SELECT * FROM t PIVOT(SUM (amount) FOR quarter IN (
163+ SELECT DISTINCT quarter
164+ FROM t2
165+ WHERE television = TRUE
166+ ORDER BY quarter))
167+ ORDER BY empid;
168+ SELECT * FROM t PIVOT(SUM (amount) FOR quarter IN (ANY) DEFAULT ON NULL (IFF(c3 % 2 = 0 ,1 ,- 1 )));
You can’t perform that action at this time.
0 commit comments