Learning SQL Queries for R Users by Djoni Darmawikarta

Learning SQL Queries for R Users by Djoni Darmawikarta

Author:Djoni Darmawikarta [Darmawikarta, Djoni]
Language: eng
Format: epub, azw3, mobi, pdf
Published: 2016-01-18T23:00:00+00:00


Factoring

Using a WITH clause you can factor out a subquery placing it above the main SELECT, and give it a name.

You can then use it in the main query by referring its name as if it is a table.

The syntax of the WITH clause is as follows.

WITH sub_query_name AS (subquery)

SELECT ...

);

The following query has the WITH factoring.

You can see that our main query is cleaner; the subquery factoring helps its clarity.

The factored subquery in the following query has more benefits as it is used more than once (i.e. twice) in the main query.

The factored subquery output is the maximum price by month.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.