pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: ruth@dannerdata.com
To: pgsql-docs@postgresql.org
Subject: recommending change to first example in 7.8.1
Date: Mon, 24 Jul 2017 21:50:40 +0000
Message-ID: <20170724215040.1455.75538@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-docs>

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/9.6/static/queries-with.html
Description:

The first example in 7.8.1 shown below includes a field called &#39;quantity&#39; to
be summed in the primary SELECT statement. I think this is a mistake. I do
not think this field exists in the WITH virtual table.

7.8.1. SELECT in WITH

The basic value of SELECT in WITH is to break down complicated queries into
simpler parts. An example is:
WITH regional_sales AS (
        SELECT region, SUM(amount) AS total_sales
        FROM orders
        GROUP BY region
     ), top_regions AS (
        SELECT region
        FROM regional_sales
        WHERE total_sales &gt; (SELECT SUM(total_sales)/10 FROM
regional_sales)
     )
SELECT region,
       product,
       SUM(quantity) AS product_units,
       SUM(amount) AS product_sales
FROM orders
WHERE region IN (SELECT region FROM top_regions)
GROUP BY region, product;


-- 
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs


view thread (2+ messages)  latest in thread

Message-ID: <20170724215040.1455.75538@wrigleys.postgresql.org>
Permalink:  ../20170724215040.1455.75538@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20170724215040.1455.75538@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: ruth@dannerdata.com
  Subject: Re: recommending change to first example in 7.8.1
  In-Reply-To: <20170724215040.1455.75538@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox