SQL SUM () Fonction
La fonction sum ()
Le SUM () retourne la somme totale d'une colonne numérique.
SUM SQL () Syntaxe
SELECT SUM(column_name) FROM table_name
SUM SQL () Exemple
Nous avons ce qui suit "Commandes" table:
| O_ID | OrderDate | OrderPrice | Client |
|---|---|---|---|
| 1 | 12/11/2008 | 1000 | Hansen |
| 2 | 23/10/2008 | 1600 | Nilsen |
| 3 | 02/09/2008 | 700 | Hansen |
| 4 | 03/09/2008 | 300 | Hansen |
| 5 | 30/08/2008 | 2000 | Jensen |
| 6 | 04/10/2008 | 100 | Nilsen |
Maintenant, nous voulons trouver la somme de tous les "OrderPrice« champs ».
Nous utilisons l'instruction SQL suivante:
SELECT SUM(OrderPrice) AS OrderTotal FROM Orders
L'ensemble de résultats se présente comme suit:
| OrderTotal |
|---|
| 5700 |

0 commentaires:
Post a Comment
HELLO VISITORS THANKS FOR YOUR VISIT AND COMMENT