mirror of
https://github.com/treffynnon/sqlstyle.guide.git
synced 2025-03-09 12:49:51 -05:00
Closes #8 by adding examples of GROUP and UNION
This commit is contained in:
parent
9f1024dfab
commit
436bbf1337
1 changed files with 17 additions and 5 deletions
|
@ -176,11 +176,23 @@ the readers eye to scan over the code and separate the keywords from the
|
|||
implementation detail. Rivers are [bad in typography][rivers], but helpful here.
|
||||
|
||||
```sql
|
||||
SELECT f.average_height, f.average_diameter
|
||||
FROM flora AS f
|
||||
WHERE f.species_name = 'Banksia'
|
||||
OR f.species_name = 'Sheoak'
|
||||
OR f.species_name = 'Wattle';
|
||||
(SELECT f.species_name,
|
||||
AVG(f.height) AS average_height, AVG(f.diameter) AS average_diameter
|
||||
FROM flora AS f
|
||||
WHERE f.species_name = 'Banksia'
|
||||
OR f.species_name = 'Sheoak'
|
||||
OR f.species_name = 'Wattle'
|
||||
GROUP BY f.species_name, f.observation_date)
|
||||
|
||||
UNION ALL
|
||||
|
||||
(SELECT b.species_name,
|
||||
AVG(b.height) AS average_height, AVG(b.diameter) AS average_diameter
|
||||
FROM botanic_garden_flora AS b
|
||||
WHERE b.species_name = 'Banksia'
|
||||
OR b.species_name = 'Sheoak'
|
||||
OR b.species_name = 'Wattle'
|
||||
GROUP BY b.species_name, b.observation_date)
|
||||
```
|
||||
|
||||
Notice that `SELECT`, `FROM`, etc. are all right aligned while the actual column
|
||||
|
|
Loading…
Reference in a new issue