Ejemplo 1: uso de la función de suma en mysql para dos condiciones de diffrenet
SELECT
SUM(CASE
WHEN status = 'Shipped' THEN quantityOrdered
END) qty_shipped,
SUM(CASE
WHEN status = 'Resolved' THEN quantityOrdered
END) qty_resolved,
SUM(CASE
WHEN status = 'Cancelled' THEN quantityOrdered
END) qty_cancelled,
SUM(CASE
WHEN status = 'On Hold' THEN quantityOrdered
END) qty_on_hold,
SUM(CASE
WHEN status = 'Disputed' THEN quantityOrdered
END) qty_on_disputed,
SUM(CASE
WHEN status = 'In Process' THEN quantityOrdered
END) qty_in_process
FROM
orderdetails
INNER JOIN
orders USING (orderNumber);
Ejemplo 2: suma columna mysql
SELECT sum( mark ) FROM `student`
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)