Skip to main content
se añadieron 83 caracteres en el cuerpo
Origen Enlace
AlJw
  • 97
  • 10

Quisiera que salga así [![Quisiera que salga así][1]][1]

[1]: https://i.sstatic.net/IUmzK.png![introducir la descripción de la imagen aquí](https://i.sstatic.net/PpcBS.png)

Quisiera que salga así

[![Quisiera que salga así][1]][1]

[1]: https://i.sstatic.net/IUmzK.png![introducir la descripción de la imagen aquí](https://i.sstatic.net/PpcBS.png)

se añadieron 126 caracteres en el cuerpo
Origen Enlace
gbianchi
  • 20.6k
  • 13
  • 40
  • 60
SELECT 
    MONTH(c.feccotizacion) as mes, 
    ies.ingresos, ies.egresos, 
    SUM(c.totalcotizacion) AS totalcotizacion, 
    ord.totalorden  
FROM cotizaciones AS c 
    LEFT JOIN ( 
        SELECT r.fecregistro, SUM(IF(r.idmovimiento = 1,r.vlrregistro,NULL)) AS ingresos, SUM(IF(r.idmovimiento = 2 AND r.idcategoria <> 8,r.vlrregistro,NULL)) AS egresos FROM registros AS r WHERE r.idmovimiento IN (1, 2) AND r.idestado <> 7 GROUP BY month(r.fecregistro)) ies 
    ON ies.fecregistro = c.feccotizacion 
    LEFT JOIN ( 
        SELECT IF(feciop IS NULL, fecicom, feciop) AS fecorden, SUM(totalorden) AS totalorden FROM ordenes WHERE id_estado <> 7 GROUP BY fecorden ) ord 
    ON ord.fecorden = c.feccotizacion  
WHERE c.id_estado <> 7 AND c.feccotizacion BETWEEN '2020-01-01' AND '2020-03-15'  
GROUP BY MONTH(c.feccotizacion) DESC
SELECT MONTH(c.feccotizacion) as mes, ies.ingresos, ies.egresos, SUM(c.totalcotizacion) AS totalcotizacion, ord.totalorden FROM cotizaciones AS c LEFT JOIN ( SELECT r.fecregistro, SUM(IF(r.idmovimiento = 1,r.vlrregistro,NULL)) AS ingresos, SUM(IF(r.idmovimiento = 2 AND r.idcategoria <> 8,r.vlrregistro,NULL)) AS egresos FROM registros AS r WHERE r.idmovimiento IN (1, 2) AND r.idestado <> 7 GROUP BY month(r.fecregistro)) ies ON ies.fecregistro = c.feccotizacion LEFT JOIN ( SELECT IF(feciop IS NULL, fecicom, feciop) AS fecorden, SUM(totalorden) AS totalorden FROM ordenes WHERE id_estado <> 7 GROUP BY fecorden ) ord ON ord.fecorden = c.feccotizacion WHERE c.id_estado <> 7 AND c.feccotizacion BETWEEN '2020-01-01' AND '2020-03-15' GROUP BY MONTH(c.feccotizacion) DESC
SELECT 
    MONTH(c.feccotizacion) as mes, 
    ies.ingresos, ies.egresos, 
    SUM(c.totalcotizacion) AS totalcotizacion, 
    ord.totalorden  
FROM cotizaciones AS c 
    LEFT JOIN ( 
        SELECT r.fecregistro, SUM(IF(r.idmovimiento = 1,r.vlrregistro,NULL)) AS ingresos, SUM(IF(r.idmovimiento = 2 AND r.idcategoria <> 8,r.vlrregistro,NULL)) AS egresos FROM registros AS r WHERE r.idmovimiento IN (1, 2) AND r.idestado <> 7 GROUP BY month(r.fecregistro)) ies 
    ON ies.fecregistro = c.feccotizacion 
    LEFT JOIN ( 
        SELECT IF(feciop IS NULL, fecicom, feciop) AS fecorden, SUM(totalorden) AS totalorden FROM ordenes WHERE id_estado <> 7 GROUP BY fecorden ) ord 
    ON ord.fecorden = c.feccotizacion  
WHERE c.id_estado <> 7 AND c.feccotizacion BETWEEN '2020-01-01' AND '2020-03-15'  
GROUP BY MONTH(c.feccotizacion) DESC
se eliminaron 17 caracteres en el cuerpo
Origen Enlace
AlJw
  • 97
  • 10
SELECT MONTH(c.feccotizacion) as mes, ies.ingresos, ies.egresos, SUM(c.totalcotizacion) AS totalcotizacion, ord.totalorden FROM cotizaciones AS c LEFT JOIN ( SELECT r.fecregistro, SUM(IF(r.idmovimiento = 1,r.vlrregistro,NULL)) AS ingresos, SUM(IF(r.idmovimiento = 2 AND r.idcategoria <> 8,r.vlrregistro,NULL)) AS egresos FROM registros AS r WHERE r.idmovimiento IN (1, 2) AND r.idestado <> 7 GROUP BY month(r.fecregistro)) ies ON ies.fecregistro = c.feccotizacion LEFT JOIN ( SELECT IF(feciop IS NULL, fecicom, feciop) AS fecorden, SUM(totalorden) AS totalorden FROM ordenes WHERE id_estado <> 7 GROUP BY fecorden ) ord ON ord.fecorden = c.feccotizacion WHERE c.id_estado <> 7 AND c.feccotizacion BETWEEN '2020-01-01' AND '2020-03-15' GROUP BY MONTH(c.feccotizacion) DESC[![introducir la descripción de la imagen aquí][1]][1]DESC

Quisiera que salga así

SELECT MONTH(c.feccotizacion) as mes, ies.ingresos, ies.egresos, SUM(c.totalcotizacion) AS totalcotizacion, ord.totalorden FROM cotizaciones AS c LEFT JOIN ( SELECT r.fecregistro, SUM(IF(r.idmovimiento = 1,r.vlrregistro,NULL)) AS ingresos, SUM(IF(r.idmovimiento = 2 AND r.idcategoria <> 8,r.vlrregistro,NULL)) AS egresos FROM registros AS r WHERE r.idmovimiento IN (1, 2) AND r.idestado <> 7 GROUP BY month(r.fecregistro)) ies ON ies.fecregistro = c.feccotizacion LEFT JOIN ( SELECT IF(feciop IS NULL, fecicom, feciop) AS fecorden, SUM(totalorden) AS totalorden FROM ordenes WHERE id_estado <> 7 GROUP BY fecorden ) ord ON ord.fecorden = c.feccotizacion WHERE c.id_estado <> 7 AND c.feccotizacion BETWEEN '2020-01-01' AND '2020-03-15' GROUP BY MONTH(c.feccotizacion) DESC[![introducir la descripción de la imagen aquí][1]][1]
SELECT MONTH(c.feccotizacion) as mes, ies.ingresos, ies.egresos, SUM(c.totalcotizacion) AS totalcotizacion, ord.totalorden FROM cotizaciones AS c LEFT JOIN ( SELECT r.fecregistro, SUM(IF(r.idmovimiento = 1,r.vlrregistro,NULL)) AS ingresos, SUM(IF(r.idmovimiento = 2 AND r.idcategoria <> 8,r.vlrregistro,NULL)) AS egresos FROM registros AS r WHERE r.idmovimiento IN (1, 2) AND r.idestado <> 7 GROUP BY month(r.fecregistro)) ies ON ies.fecregistro = c.feccotizacion LEFT JOIN ( SELECT IF(feciop IS NULL, fecicom, feciop) AS fecorden, SUM(totalorden) AS totalorden FROM ordenes WHERE id_estado <> 7 GROUP BY fecorden ) ord ON ord.fecorden = c.feccotizacion WHERE c.id_estado <> 7 AND c.feccotizacion BETWEEN '2020-01-01' AND '2020-03-15' GROUP BY MONTH(c.feccotizacion) DESC

Quisiera que salga así

Origen Enlace
AlJw
  • 97
  • 10
Loading