pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
recommending change to first example in 7.8.1
2+ messages / 2 participants
[nested] [flat]

* recommending change to first example in 7.8.1
@ 2017-07-24 21:50  ruth@dannerdata.com
  0 siblings, 1 reply; 2+ messages in thread

From: ruth@dannerdata.com @ 2017-07-24 21:50 UTC (permalink / raw)
  To: pgsql-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 'quantity' 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 > (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


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: recommending change to first example in 7.8.1
@ 2017-07-25 22:27  David G. Johnston <david.g.johnston@gmail.com>
  parent: ruth@dannerdata.com
  0 siblings, 0 replies; 2+ messages in thread

From: David G. Johnston @ 2017-07-25 22:27 UTC (permalink / raw)
  To: ruth@dannerdata.com <ruth@dannerdata.com>; +Cc: pgsql-docs

On Monday, July 24, 2017, <ruth@dannerdata.com> wrote:

> 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.


It isn't.


> I do
> not think this field exists in the WITH virtual table
>

It wouldn't matter if it did since in the main query the only from item is
the orders table which can be reasonably assumed to contain a quantity
column.

David J.

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2017-07-25 22:27 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-07-24 21:50 recommending change to first example in 7.8.1 ruth@dannerdata.com
2017-07-25 22:27 ` David G. Johnston <david.g.johnston@gmail.com>

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