Bonjour Stéphane,
Ceci pourrait marcher:
select id,
date_absence,
(select count(id)
from presences as innerPresences
where presences.id = innerPresences.id) as quantite
from presences;
Il s'agit d'une sous-requêtes corrélées:
https://sqlpro.developpez.com/cours/sqlaz/sousrequetes/#L2
Bien à toi.
Le 20.10.2020 00:37, Stéphane Santon a écrit :
Bonjour,
Je cherche à créer une requête SQL sous Base qui me rajoute un champ
"calculé", le calcul étant le nombre d'enregistrements qui ont un
champ à la même valeur.
Depuis :
| id | date_absence|
| Larry | 05/09/2020 |
| Sarah | 07/09/2020 |
| Sarah | 12/09/2020 |
| Sarah | 18/09/2020 |
| Sarah | 01/10/2020 |
| Anna | 25/09/2020 |
| Anna | 27/09/2020 |
| Anna | 05/10/2020 |
| Henri | 21/09/2020 |
| Henri | 25/09/2020 |
Je veux sortir ça :
| id | date_absence| Qté |
| Larry | 05/09/2020 | 1 |
| Sarah | 07/09/2020 | 4 |
| Sarah | 12/09/2020 | 4 |
| Sarah | 18/09/2020 | 4 |
| Sarah | 01/10/2020 | 4 |
| Anna | 25/09/2020 | 3 |
| Anna | 27/09/2020 | 3 |
| Anna | 05/10/2020 | 3 |
| Henri | 14/09/2020 | 2 |
| Henri | 25/09/2020 | 2 |
Un truc du style
SELECT
"Feuille1"."id" AS id_ref,
"date_absence",
(SELECT COUNT(*) FROM "Feuille1" WHERE "id" == "id_ref")
FROM "Feuille1"
Merci
--
Envoyez un mail à users+unsubscribe@fr.libreoffice.org pour vous désinscrire
Les archives de la liste sont disponibles à https://listarchives.libreoffice.org/fr/users/
Privacy Policy: https://www.documentfoundation.org/privacy
Context
Privacy Policy |
Impressum (Legal Info) |
Copyright information: Unless otherwise specified, all text and images
on this website are licensed under the
Creative Commons Attribution-Share Alike 3.0 License.
This does not include the source code of LibreOffice, which is
licensed under the Mozilla Public License (
MPLv2).
"LibreOffice" and "The Document Foundation" are
registered trademarks of their corresponding registered owners or are
in actual use as trademarks in one or more countries. Their respective
logos and icons are also subject to international copyright laws. Use
thereof is explained in our
trademark policy.