generated from dataforgoodfr/d4g-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from dataforgoodfr/gauge-viz
Gauge viz
- Loading branch information
Showing
5 changed files
with
164 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
-- Listing des modifications faites sur la base de données | ||
-- POC requête pour afficher les fréquences 17/07/2024 | ||
SELECT | ||
o.id AS id_site, | ||
ls.name AS main_lichenspecies, | ||
COUNT(l.id) AS frequency | ||
FROM | ||
main_observation o | ||
JOIN main_tree t ON o.id = t.observation_id | ||
JOIN main_lichen l ON o.id = l.observation_id | ||
JOIN main_lichenspecies ls ON l.species_id = ls.id | ||
|
||
GROUP BY | ||
o.id, ls.name | ||
|
||
ORDER BY o.id, frequency DESC; | ||
|
||
-- Pour la commandline PSQL | ||
SELECT o.id AS id_site, ls.name AS main_lichenspecies, COUNT(l.id) AS frequency FROM main_observation o JOIN main_tree t ON o.id = t.observation_id JOIN main_lichen l ON o.id = l.observation_id JOIN main_lichenspecies ls ON l.species_id = ls.id GROUP BY o.id, ls.name ORDER BY o.id, frequency DESC; | ||
|
||
-- Créer une table view récupérable dans le modèle intégrée dans la base de données le 17/07/2024 | ||
CREATE VIEW lichen_frequency AS | ||
SELECT | ||
o.id AS id_site, | ||
ls.name AS main_lichenspecies, | ||
COUNT(l.id) AS frequency | ||
FROM | ||
main_observation o | ||
JOIN main_tree t ON o.id = t.observation_id | ||
JOIN main_lichen l ON o.id = l.observation_id | ||
JOIN main_lichenspecies ls ON l.species_id = ls.id | ||
GROUP BY | ||
o.id, ls.name | ||
ORDER BY | ||
o.id, frequency DESC; | ||
|
||
-- Pour la commandline PSQL | ||
CREATE VIEW lichen_frequency AS SELECT o.id AS id_site, ls.name AS main_lichenspecies, COUNT(l.id) AS frequency FROM main_observation o JOIN main_tree t ON o.id = t.observation_id JOIN main_lichen l ON o.id = l.observation_id JOIN main_lichenspecies ls ON l.species_id = ls.id GROUP BY o.id, ls.name ORDER BY o.id, frequency DESC; | ||
|
||
|
||
-- Update SQL command | ||
CREATE VIEW lichen_frequency AS | ||
SELECT | ||
ROW_NUMBER() OVER (ORDER BY o.id, ls.name) AS id, | ||
o.id AS id_site, | ||
ls.name AS main_lichenspecies, | ||
COUNT(l.id) AS frequency | ||
FROM | ||
main_observation o | ||
JOIN main_tree t ON o.id = t.observation_id | ||
JOIN main_lichen l ON o.id = l.observation_id | ||
JOIN main_lichenspecies ls ON l.species_id = ls.id | ||
GROUP BY | ||
o.id, ls.name | ||
ORDER BY | ||
o.id, frequency DESC; | ||
|
||
CREATE VIEW lichen_frequency AS SELECT ROW_NUMBER() OVER (ORDER BY o.id, ls.name) AS id, o.id AS id_site, ls.name AS main_lichenspecies, COUNT(l.id) AS frequency FROM main_observation o JOIN main_tree t ON o.id = t.observation_id JOIN main_lichen l ON o.id = l.observation_id JOIN main_lichenspecies ls ON l.species_id = ls.id GROUP BY o.id, ls.name ORDER BY o.id, frequency DESC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters