Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT productos.id,productos.nombre,productos.isbn13,precio, stockfirme
- -IF(ventas.cantidad IS NULL,0,ventas.cantidad)
- -IF(egresos.cantidad IS NULL,0,egresos.cantidad)
- +IF(ingresos.cantidad IS NULL,0,ingresos.cantidad) as firmes from actualstocks
- INNER JOIN productos on productos.id = actualstocks.id
- LEFT JOIN (
- select ventaproductos.id_producto, sum(ventaproductos.cantidad) as cantidad from ventas
- inner join ventaproductos on ventas.id = ventaproductos.id_venta
- where id_sucursal = 7 and fechaventa<"2009-06-01"
- group by ventaproductos.id_producto
- ) AS ventas on ventas.id_producto = actualstocks.id_producto
- LEFT JOIN (select stockproductos.id_producto, sum(stockproductos.cantidad) as cantidad from stocks
- inner join stockproductos on stockproductos.id_stock = stocks.id
- where id_sucursal = 7 and fechaingreso<"2009-06-01" and stocks.id_tipostock in (2)
- group by stockproductos.id_producto
- ) AS ingresos on ingresos.id_producto = actualstocks.id_producto
- LEFT JOIN (select stockproductos.id_producto, sum(stockproductos.cantidad) as cantidad from stocks
- inner join stockproductos on stockproductos.id_stock = stocks.id
- where id_sucursal = 7 and fechaingreso<"2009-06-01" and stocks.id_tipostock in (11)
- group by stockproductos.id_producto
- ) AS egresos on egresos.id_producto = actualstocks.id_producto
- INNER JOIN precios on precios.id_producto = actualstocks.id_producto
- where actualstocks.id_sucursal = 7 and stockfirme
- -IF(ventas.cantidad IS NULL,0,ventas.cantidad)
- -IF(egresos.cantidad IS NULL,0,egresos.cantidad)
- +IF(ingresos.cantidad IS NULL,0,ingresos.cantidad)>0 order by productos.nombre;
Add Comment
Please, Sign In to add comment