Home Explore Blog CI



postgresql

18th chunk of `doc/src/sgml/ref/psql-ref.sgml`
8882ddef6873cb38a31529b3e1bb0bdf0ec416ad830f7a300000000100000fa0

      <varlistentry id="app-psql-meta-command-copyright">
        <term><literal>\copyright</literal></term>
        <listitem>
        <para>
        Shows the copyright and distribution terms of
        <productname>PostgreSQL</productname>.
        </para>
        </listitem>
      </varlistentry>


      <varlistentry id="app-psql-meta-commands-crosstabview">
        <term><literal>\crosstabview [
            <replaceable class="parameter">colV</replaceable>
            [ <replaceable class="parameter">colH</replaceable>
            [ <replaceable class="parameter">colD</replaceable>
            [ <replaceable class="parameter">sortcolH</replaceable>
            ] ] ] ] </literal></term>
        <listitem>
        <para>
        Executes the current query buffer (like <literal>\g</literal>) and
        shows the results in a crosstab grid.
        The query must return at least three columns.
        The output column identified by <replaceable class="parameter">colV</replaceable>
        becomes a vertical header and the output column identified by
        <replaceable class="parameter">colH</replaceable>
        becomes a horizontal header.
        <replaceable class="parameter">colD</replaceable> identifies
        the output column to display within the grid.
        <replaceable class="parameter">sortcolH</replaceable> identifies
        an optional sort column for the horizontal header.
        </para>

        <para>
        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,
        <replaceable class="parameter">colV</replaceable> is taken as column 1
        and <replaceable class="parameter">colH</replaceable> as column 2.
        <replaceable class="parameter">colH</replaceable> must differ from
        <replaceable class="parameter">colV</replaceable>.
        If <replaceable class="parameter">colD</replaceable> is not
        specified, then there must be exactly three columns in the query
        result, and the column that is neither
        <replaceable class="parameter">colV</replaceable> nor
        <replaceable class="parameter">colH</replaceable>
        is taken to be <replaceable class="parameter">colD</replaceable>.
        </para>

        <para>
        The vertical header, displayed as the leftmost column, contains the
        values found in column <replaceable class="parameter">colV</replaceable>, in the
        same order as in the query results, but with duplicates removed.
        </para>

        <para>
        The horizontal header, displayed as the first row, contains the values
        found in column <replaceable class="parameter">colH</replaceable>,
        with duplicates removed.  By default, these appear in the same order
        as in the query results.  But if the
        optional <replaceable class="parameter">sortcolH</replaceable> argument is given,
        it identifies a column whose values must be integer numbers, and the
        values from <replaceable class="parameter">colH</replaceable> will
        appear in the horizontal header sorted according to the
        corresponding <replaceable class="parameter">sortcolH</replaceable> values.
        </para>

        <para>
        Inside the crosstab grid, for each distinct value <literal>x</literal>
        of <replaceable class="parameter">colH</replaceable> and each distinct
        value <literal>y</literal>
        of <replaceable class="parameter">colV</replaceable>, the cell located
        at the intersection <literal>(x,y)</literal> contains the value of
        the <literal>colD</literal> column in the query result row for which
        the value of <replaceable class="parameter">colH</replaceable>
        is <literal>x</literal> and the value
        of <replaceable class="parameter">colV</replaceable>
        is <literal>y</literal>.  If there is no such row, the cell is empty.  If
    

Title: psql Meta-Commands: \copyright, \crosstabview (Continued)
Summary
This section continues the description of the \crosstabview meta-command. It details the parameters colV, colH, colD, and sortcolH and how they are used to structure the crosstab grid. It explains how to specify the columns, the order of values in the headers, and how the data is populated within the grid based on the query results. The \copyright command shows the copyright and distribution terms of PostgreSQL.