Created
March 28, 2014 19:49
-
-
Save MarioCares/9841590 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT orco_pk_id, orco_fk_cuclapre, (orco_iva + orco_impespecifico + orco_total) AS total_orden, | |
( | |
SELECT COUNT(*) FROM orden WHERE deor_fk_orco = orco_pk_id | |
) AS pagos, | |
COALESCE( | |
(SELECT SUM(deor_cantidad*deor_preciounitario-deor_descuento) AS total | |
FROM detalleorden | |
WHERE deor_fk_orco = orco_pk_id), 0 | |
) AS total_detalle | |
FROM `ordencompra` | |
WHERE orco_fk_estado NOT IN (6,7) AND orco_fecha REGEXP '2014-01' LIMIT 2000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment