Guest User

Untitled

a guest
Jul 11th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. SELECT productos.id,productos.nombre,productos.isbn13,precio, stockfirme
  2. -IF(ventas.cantidad IS NULL,0,ventas.cantidad)
  3. -IF(egresos.cantidad IS NULL,0,egresos.cantidad)
  4. +IF(ingresos.cantidad IS NULL,0,ingresos.cantidad) as firmes from actualstocks
  5. INNER JOIN productos on productos.id = actualstocks.id
  6. LEFT JOIN (
  7. select ventaproductos.id_producto, sum(ventaproductos.cantidad) as cantidad from ventas
  8. inner join ventaproductos on ventas.id = ventaproductos.id_venta
  9. where id_sucursal = 7 and fechaventa<"2009-06-01"
  10. group by ventaproductos.id_producto
  11. ) AS ventas on ventas.id_producto = actualstocks.id_producto
  12.  
  13. LEFT JOIN (select stockproductos.id_producto, sum(stockproductos.cantidad) as cantidad from stocks
  14. inner join stockproductos on stockproductos.id_stock = stocks.id
  15. where id_sucursal = 7 and fechaingreso<"2009-06-01" and stocks.id_tipostock in (2)
  16. group by stockproductos.id_producto
  17. ) AS ingresos on ingresos.id_producto = actualstocks.id_producto
  18.  
  19. LEFT JOIN (select stockproductos.id_producto, sum(stockproductos.cantidad) as cantidad from stocks
  20. inner join stockproductos on stockproductos.id_stock = stocks.id
  21. where id_sucursal = 7 and fechaingreso<"2009-06-01" and stocks.id_tipostock in (11)
  22. group by stockproductos.id_producto
  23. ) AS egresos on egresos.id_producto = actualstocks.id_producto
  24. INNER JOIN precios on precios.id_producto = actualstocks.id_producto
  25. where actualstocks.id_sucursal = 7 and stockfirme
  26. -IF(ventas.cantidad IS NULL,0,ventas.cantidad)
  27. -IF(egresos.cantidad IS NULL,0,egresos.cantidad)
  28. +IF(ingresos.cantidad IS NULL,0,ingresos.cantidad)>0 order by productos.nombre;
Add Comment
Please, Sign In to add comment