select v,h,c from v_data \crosstabview -- v|h|c v1|h2|foo v2|h1|bar v1|h0|baz v0|h4|qux -- v|h2|h1|h0|h4 v1|foo||baz| v2||bar|| v0||||qux select v,h,c from v_data order by 1 \crosstabview v h c -- v|h|c v0|h4|qux v1|h2|foo v1|h0|baz v2|h1|bar -- v|h4|h2|h0|h1 v0|qux||| v1||foo|baz| v2||||bar select v,h,c from v_data order by 1 desc \crosstabview v h c -- v|h|c v2|h1|bar v1|h2|foo v1|h0|baz v0|h4|qux -- v|h1|h2|h0|h4 v2|bar||| v1||foo|baz| v0||||qux select v,h,c from v_data order by 2 \crosstabview v h c -- v|h|c v1|h0|baz v2|h1|bar v1|h2|foo v0|h4|qux -- v|h0|h1|h2|h4 v1|baz||foo| v2||bar|| v0||||qux select v,h,c,row_number() over(order by h) as hsort from v_data order by 1 \crosstabview v h c -- v|h|c|hsort v0|h4|qux|4 v1|h0|baz|1 v1|h2|foo|3 v2|h1|bar|2 -- v|h4|h0|h2|h1 v0|qux||| v1||baz|foo| v2||||bar select v,h,c,row_number() over(order by h) as hsort from v_data order by 1 \crosstabview v h c hsort -- v|h|c|hsort v0|h4|qux|4 v1|h0|baz|1 v1|h2|foo|3 v2|h1|bar|2 -- v|h0|h1|h2|h4 v0||||qux v1|baz||foo| v2||bar|| select v,h,c,row_number() over(order by h desc) as hsort from v_data order by 1 \crosstabview v h c hsort -- v|h|c|hsort v0|h4|qux|1 v1|h2|foo|2 v1|h0|baz|4 v2|h1|bar|3 -- v|h4|h2|h1|h0 v0|qux||| v1||foo||baz v2|||bar| select v,to_char(d,'Mon') as m, c from v_data order by 1 \crosstabview v m c -- v|m|c v0|Jul|qux v1|Apr|foo v1|Jul|baz v2|Jan|bar -- v|Jul|Apr|Jan v0|qux|| v1|baz|foo| v2|||bar select v,to_char(d,'Mon') as m, c from v_data order by d \crosstabview v m c -- v|m|c v2|Jan|bar v1|Apr|foo v1|Jul|baz v0|Jul|qux -- v|Jan|Apr|Jul v2|bar|| v1||foo|baz v0|||qux select v,to_char(d,'Mon') as m, c, extract(month from d) as mnum from v_data order by v \crosstabview v m c mnum -- v|m|c|mnum v0|Jul|qux|7 v1|Apr|foo|4 v1|Jul|baz|7 v2|Jan|bar|1 -- v|Jan|Apr|Jul v0|||qux v1||foo|baz v2|bar|| select v,to_char(d,'Mon') as m, c, -1*extract(month from d) as revnum from v_data order by v \crosstabview v m c revnum -- v|m|c|revnum v0|Jul|qux|-7 v1|Apr|foo|-4 v1|Jul|baz|-7 v2|Jan|bar|-1 -- v|Jul|Apr|Jan v0|qux|| v1|baz|foo| v2|||bar SELECT first, second, first > 2 AS gt2 FROM my_table \crosstabview first second -- first|second|gt2 1|one|f 2|two|f 3|three|t 4|four|t -- first|one|two|three|four 1|f||| 2||f|| 3|||t| 4||||t SELECT t1.first as A, t2.first+100 AS B, t1.first*(t2.first+100) as AxB, row_number() over(order by t2.first) AS ord FROM my_table t1 CROSS JOIN my_table t2 ORDER BY 1 DESC \crosstabview A B AxB ord -- a|b|axb|ord 4|103|412|11 4|104|416|13 4|102|408|7 4|101|404|4 3|104|312|16 3|101|303|3 3|102|306|6 3|103|309|9 2|101|202|2 2|104|208|14 2|102|204|5 2|103|206|10 1|102|102|8 1|103|103|12 1|104|104|15 1|101|101|1 -- a|101|102|103|104 4|404|408|412|416 3|303|306|309|312 2|202|204|206|208 1|101|102|103|104