You are on page 1of 2

SELECT cg.cg_nombre AS clase, cg.cg_total AS total, d.division_nombre AS divisio n, SUM( d.

division_total ) AS valor FROM clasedegastos AS cg INNER JOIN division AS d ON cg.cg_id = d.cg_id GROUP BY 1 , 2 LIMIT 0 , 30

SELECT d.division_nombre AS division, d.division_total AS total, s.seccion_nombr e AS seccion, SUM( s.seccion_total ) AS valor FROM division AS d INNER JOIN seccion AS s ON d.division_id = s.division_id GROUP BY 1,2 LIMIT 0 , 30

SELECT s.seccion_nombre AS seccion, s.seccion_total AS total, c.categoria_nombre AS categoria, SUM( c.categoria_total ) AS valor FROM seccion AS s INNER JOIN categoria AS c ON s.seccion_id = c.seccion_id GROUP BY 1,2 LIMIT 0 , 30

SELECT c.categoria_nombre AS categoria, c.categoria_total AS total, g.gasto_desc rip AS gasto, SUM( g.egreso_soles ) AS valor FROM categoria AS c INNER JOIN gasto AS g ON c.categoria_id = g.categoria_id GROUP BY 1,2 LIMIT 0 , 30

/* SELECT d.division_nombre AS division, d.division_total AS total, s.seccion_nombr e AS seccion, SUM( s.seccion_total ) AS valor FROM division AS d INNER JOIN seccion AS s ON d.division_id = s.division_id WHERE d.division_nombre = 'Materiales Indirectos' GROUP BY 1 , 2, d.division_id LIMIT 0 , 30 */ /* SELECT s.seccion_nombre AS seccion, s.seccion_total AS total, c.categoria_nombre AS categoria, SUM( c.categoria_total ) -- AS valor FROM seccion AS s INNER JOIN categoria AS c ON s.seccion_id = c.seccion_id WHERE s.seccion_nombre = 'Sin Seccion' GROUP BY 1 , 2 LIMIT 0 , 300 */ /* SELECT c.categoria_nombre AS categoria, c.categoria_total AS total, g.gasto_desc rip AS gasto, SUM( g.egreso_soles ) AS valor FROM categoria AS c

INNER JOIN gasto AS g ON c.categoria_id = g.categoria_id and c.categoria_nombre = 'Sin Categoria' GROUP BY 1,2,g.gasto_id LIMIT 0 , 300 */ Realizar sumas para corregir datos /** UPDATE categoria as cat set categoria_total = ( SELECT SUM( g.egreso_soles ) FROM categoria AS c INNER JOIN gasto AS g ON c.categoria_id = g.categoria_id WHERE cat.categoria_id = c.categoria_id) **/

You might also like