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,
9
1
2
3
SELECT SUM(revenue)
FROM sells
WHERE item = 'Sofa'
123SELECT SUM(revenue) FROM sells WHERE item = 'Sofa'
Please note, that
SUM
function works only with numeric columns.
Compito
Swipe to start coding
From the audi_cars
table calculate the total tax
for all RS4 cars.
Soluzione
9
1
2
3
SELECT SUM(tax)
FROM audi_cars
WHERE model = 'RS4'
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 3. Capitolo 2
9
1
No query executed yet... |
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione