'How can I get the amount of each invoice if I have the query to get the total amount?
This query shows the total amount of all the invoices. How can I show a list with the total amount of each invoice?
Now ---> 1300 and I want --> [v.cod and total of each invoice]
Invoice# $$
0001 202
0002 533
0003 232
0004 2666
SELECT (
IFNULL((SELECT ( round( sum(l.unidades*l.importe) ,2 ) - round( sum(l.unidades*( (l.importe*(l.dto/100)))),2 ) )
FROM venta v, lventa l, articulo a, familias f
WHERE l.venta = v.id
AND l.articulo = a.id
AND f.id = a.familia
AND v.fecha_exp LIKE '2022-02%'
AND v.tipo_servicio = 'productoA'
),0)+
IFNULL((SELECT ( round( sum(l.unidades*l.importe) ,2 ) - round( sum(l.unidades*( (l.importe*(l.dto/100)))),2 ) )
FROM venta v, lventa l, articulo a, cliente c
WHERE l.venta = v.id
AND l.articulo = a.id
AND v.fecha_exp LIKE '2022-02%'
AND v.tipo_servicio <> 'productoA'
AND c.id = v.cliente
AND c.id <> 1
AND c.id <> 2 AND c.id <> 3
AND (operacion = 'FA' OR operacion = 'AB' OR operacion = 'TI')),0)
-IFNULL((select SUM(importe) AS importe
FROM albaran_ext al, venta v
WHERE v.id = al.venta
AND v.tipo_servicio = 'productoA'
AND v.fecha LIKE '2022-02%'),0)
-IFNULL((select SUM(importe) AS importe
FROM albaran_ext al, venta v
WHERE v.id = al.venta
AND v.cliente NOT IN ('1', '2', '3')
AND v.fecha LIKE '2022-02%'),0))
;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
