You are on page 1of 1

SELECT

/* DATE_FORMAT(`comprobanteemitido`.`fechaemision`,'%d-%m-%Y') AS fechaemisi
on,
(CASE
WHEN `comprobanteemitido`.`idtipocomprobante` =1 THEN CONCAT('Fact .', `c
omprobanteemitido`.`serie`,' - ',`comprobanteemitido`.`numeracion`)
WHEN `comprobanteemitido`.`idtipocomprobante` =2 THEN CONCAT('Bol .', `c
omprobanteemitido`.`serie`,' - ',`comprobanteemitido`.`numeracion` )
WHEN `comprobanteemitido`.`idtipocomprobante` =3 THEN CONCAT('Not.P .', `c
omprobanteemitido`.`serie`,' - ',`comprobanteemitido`.`numeracion`)
END ) AS 'Nº Comprobante',
detallecomprobanteemitido.`idarticulo`, */
detallecomprobanteemitido.`cantidad` AS cantidad,
detallecomprobanteemitido.`precio` AS precio,
detallecomprobanteemitido.`descuento` AS descuento,
detallecomprobanteemitido.`importe` AS importe,
getCategory(detallecomprobanteemitido.`idarticulo`) as categoria,
(select sum(importe) from detallecomprobanteemitido
where getCategory(idarticulo) not in (13,14,1)) as 'Inect. Todos ',
(select sum(importe) from detallecomprobanteemitido
where getCategory(idarticulo)=13) as 'Linea sine-3 ',
(select sum(importe) from detallecomprobanteemitido
where getCategory(idarticulo)=14) as 'Tot. Fert.',
(select ifnull(sum(importe),0) from detallecomprobanteemitido
where getCategory(idarticulo)=1) as 'Vta. Ajena'
FROM
`comprobanteemitido` comprobanteemitido INNER JOIN `detallecomprobanteemiti
do` detallecomprobanteemitido ON comprobanteemitido.`idcomprobanteemitido` = det
allecomprobanteemitido.`idcomprobanteemitido`
where comprobanteemitido.`idtipocomprobante` in ('01','02','03');

You might also like