Código MySQL:
Ver originalsum(sbc.total_cost_partides
), (SELECT id_article
, ".$anyf."_lin_tickets.total
as total_euros
, ".$anyf."_lin_tickets.partides
as total_partides
, ".$anyf."_lin_tickets.pes
as total_pes
, ".$anyf."_lin_tickets.cost
* (".$anyf."_lin_tickets.partides
) as total_cost_partides
, ".$anyf."_lin_tickets.cost
* (".$anyf."_lin_tickets.pes
/ 1000) as total_cost_pes
, iva
ON ".$anyf."_lin_tickets.id_ticket
= ".$anyf."_tickets.id_ticket
WHERE ".$anyf."_tickets.id_tenda
= ".$id_tenda." AND ".$anyf."_tickets.
data >= ".$datad." AND ".$anyf."_tickets.anulat
= 0 AND ".$anyf."_tickets.total
> 0 SELECT id_article
,".$anyd."_lin_tickets.total
as total_euros
, ".$anyd."_lin_tickets.partides
as total_partides
, ".$anyd."_lin_tickets.pes
as total_pes
, ".$anyd."_lin_tickets.cost
* (".$anyd."_lin_tickets.partides
) as total_cost_partides
, ".$anyd."_lin_tickets.cost
* (".$anyd."_lin_tickets.pes
/ 1000) as total_cost_pes
, iva
ON ".$anyd."_lin_tickets.id_ticket
= ".$anyd."_tickets.id_ticket
WHERE ".$anyd."_tickets.id_tenda
= ".$id_tenda." AND ".$anyd."_tickets.
data <= ".$dataf." AND ".$anyd."_tickets.anulat
= 0 AND ".$anyd."_tickets.total
> 0 )
no se què és ".$wlin_tickets." linia 15 i 28.
No se donde tienes el iva, ni si es un valor.... o el tipo....
Los calculos de coste no se si estaran bien...
La idea es que la subquery (sbc) selecciona los registros a tener en cuenta y la "super"query los agrega (SUM)
Código pre:
Ver originalSuperquery SUMA
Sbc Seleciona
Sbc1 selecciona anyo 1
UNION ALL
Sbc2 selecciona anyo 2