Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre SUMming values | Aggregating
SQL Basics

book
SUMming values

There is one more function that has to be implemented - function for summing values. For example, we may want to calculate the total revenue for a certain item.

To sum values in column use SUM function followed by column which values you want to sum. For our abstract example,

SELECT SUM(revenue)
FROM sells
WHERE item = 'Sofa'
123
SELECT SUM(revenue) FROM sells WHERE item = 'Sofa'
copy

Please note, that SUM function works only with numeric columns.

Tâche

Swipe to start coding

From the audi_cars table calculate the total tax for all RS4 cars.

Solution

SELECT SUM(tax)
FROM audi_cars
WHERE model = 'RS4'

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 3. Chapitre 2
single

single


Query ResultQuery Result
No query executed yet...

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

some-alt