PROFESSIONAL NEWSGROUPS
WINDEV
,
WEBDEV
and
WINDEV Mobile
Home
|
Recent messages
|
Connect
|
Sign out
|
English
Home
→
Reports & Queries
→
Requete SQL multi colonne
Requete SQL multi colonne
Started by Jean-François P, Apr., 11 2019 9:56 AM - 4 replies
Connect yourself…
Jean-François P
#1
Registered member
97 messages
Popularité : +1 (1 vote)
Posted on April, 11 2019 - 9:56 AM
Bonjour,
Je suis assez novice en sql et je voulais savoir si il est possible de sommer deux colonnes en fonctions de deux autres colonnes.
Je m'explique :
J'ai ma BDD avec mes 5 colonnes
- Date
- Mode de paiement 1
- Mode de paiement 2
- Montant paiement 1
- Montant paiement 2
Est il possible de faire une somme des paiements en fonction du mode de paiement et de la date?
Bien cordialement
Jef
Report
0
0
Jean-François P
#2
Registered member
97 messages
Popularité : +1 (1 vote)
Posted on April, 11 2019 - 10:12 AM
Exemple :
Date | Mode de paiement 1 | Mode de paiement 2 | Montant paiement 1 | Montant paiement 2
01/02/2019 | Espèce | Chèque | 2€ | 2€
01/02/2019 | Chèque | CB | 4€ | 4€
02/02/2019 | CB | Espèce | 6€ | 6€
02/02/2019 | Espèce | CB | 2€ | 2€
03/02/2019 | CB | Chèque | 4€ | 4€
03/02/2019 | Chèque | Espèce | 6€ | 6€
Le résultat serait :
01/02/2019 | Espèce | 2€
01/02/2019 | Chèque | 6€
01/02/2019 | CB | 4€
02/02/2019 | Espèce | 8€
02/02/2019 | Chèque | 0€
02/02/2019 | CB | 8€
03/02/2019 | Espèce | 6€
03/02/2019 | Chèque | 10€
03/02/2019 | CB | 4€
Je sèche vraiment, merci de votre aide.
Bien cordialement
Jef
Report
0
0
WindevMan
#3
Registered member
2 messages
Posted on April, 17 2019 - 4:57 PM
il suffit de faire un SUM et un GROUP BY
Report
0
0
Britneymcdaniel
#4
Registered member
5 messages
Posted on July, 29 2022 - 1:54 PM
I think You have to try this:
UPDATE table1
SET a = t2.a, b = t2.b, .......
FROM table2 t2
WHERE table1.id = t2.id
That should work in most SQL dialects, excluding Oracle.
And yes - it's a lot of typing - it's the way SQL does this.
Report
0
0
Britneymcdaniel
#5
Registered member
5 messages
Posted on July, 30 2022 - 7:24 AM
Britneymcdaniel escribió:
I think You have to try this:
https://www.kohlsfeedback.onl/
UPDATE table1
SET a = t2.a, b = t2.b, .......
FROM table2 t2
WHERE table1.id = t2.id
That should work in most SQL dialects, excluding Oracle.
And yes - it's a lot of typing - it's the way SQL does this.
In the real world, you will often want to select multiple columns. Luckily, SQL makes this really easy. To select multiple columns from a table, simply separate the column names with commas!
Report
0
0
→ Go back to Reports & Queries
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (earlier versions)
WEBDEV (earlier versions)
WINDEV Mobile (earlier versions)
Reports & Queries
Off-topic
Tools
Français
English
Español
Portuguesa
Close this window
Search type
Only topics
All the messages
Search period
Any time
Past hour
Past 24 hours
Past week
Past month
Past year
Cancel
Preview of your message
Adding an image
Import an image from a URL
Send an image from a file of your disk
Drop a file or click "Browse..."
or
Cancel
0%
WLanguage
SQL
XML, HTML
JAVA, Javascript
Text