\crosstabview
Executes the current query buffer (like \g ) and shows the results in a crosstab grid. The query must return at least three columns. The output column identified by colV becomes a vertical header and the output column identified by colH becomes a horizontal header. colD identifies the output column to display within the grid. sortcolH identifies an optional sort column for the horizontal header.
Reading PG 18·Select a recorded version
- Client
- psql 18.7
- Case-sensitive spelling
- \crosstabview
- command
- \crosstabview
- manual path
- app-psql.html#APP-PSQL-META-COMMANDS-CROSSTABVIEW
- modifiers
- Unknown
- signature
- \crosstabview [ colV [ colH [ colD [ sortcolH ] ] ] ]
- spellings
- \crosstabview
Definition PG 18
\crosstabview [colV[colH[colD[sortcolH] ] ] ]Executes the current query buffer (like
\g) and shows the results in a crosstab grid. The query must return at least three columns. The output column identified bycolVbecomes a vertical header and the output column identified bycolHbecomes a horizontal header.colDidentifies the output column to display within the grid.sortcolHidentifies an optional sort column for the horizontal header.Each column specification can be a column number (starting at 1) or a column name. The usual SQL case folding and quoting rules apply to column names. If omitted,
colVis taken as column 1 andcolHas column 2.colHmust differ fromcolV. IfcolDis not specified, then there must be exactly three columns in the query result, and the column that is neithercolVnorcolHis taken to becolD.The vertical header, displayed as the leftmost column, contains the values found in column
colV, in the same order as in the query results, but with duplicates removed.The horizontal header, displayed as the first row, contains the values found in column
colH, with duplicates removed. By default, these appear in the same order as in the query results. But if the optionalsortcolHargument is given, it identifies a column whose values must be integer numbers, and the values fromcolHwill appear in the horizontal header sorted according to the correspondingsortcolHvalues.Inside the crosstab grid, for each distinct value
xofcolHand each distinct valueyofcolV, the cell located at the intersection(x,y)contains the value of thecolDcolumn in the query result row for which the value ofcolHisxand the value ofcolVisy. If there is no such row, the cell is empty. If there are multiple such rows, an error is reported.
Exact case-sensitive spellings
\crosstabview
Spellings in this manual definition
| Command | Documented suffix modifiers |
|---|---|
| \crosstabview | None listed in this signature |
Compare versions
Complete source facts
documentation revision
{"inputs":[{"file":"app-psql.html","kind":"same-version-reviewed-manual","locale":"en","sha256":"af50448485df02bdef2b72b8347192ba029c7082b8d0392ecb17db44ad533aaf","version":"18.7"},{"file":"app-psql.html","kind":"same-version-reviewed-manual","locale":"zh-Hans","sha256":"cb475c53a16d9e06358f5e6c9c5649645db92568cfd319f230c62c9f57ae090b","version":"18.7"}],"release":"18.7","runtime_remeasured":false,"source_revision":"pgdoc:b9f0e7232f60f380d642ac9b99226606c254b552"}Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · 1b2d62b4845aa46374f2cb680f95d3392322cc8128646992ae4e18d0e7084915
Text language: en · 1b2d62b4845aa46374f2cb680f95d3392322cc8128646992ae4e18d0e7084915