Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/11/2010, 10:26
Avatar de robertgustavo
robertgustavo
 
Fecha de Ingreso: marzo-2008
Ubicación: Camaná - Arequipa
Mensajes: 213
Antigüedad: 16 años, 1 mes
Puntos: 4
Left outer join DE SQL SERVER EN access

Hola hace poco hize una consulta para un kardex, en sql server: y tengo que hacerlo ahra para access, ayuda please

Cita:
@FechaInicio datetime,
@FechaFin datetime
As
Select P.Id
,P.descripcion
,P.categoria
,P.marca
,P.StockInicial
,isnull(J.Entrada,0)+ isnull(M.DevCliente,0)+ isnull(B.DevProveedor,0) Entradas
,isnull(S.Salida,0) Salidas
,isnull(J.Entrada,0)+ isnull(M.DevCliente,0)+ isnull(B.DevProveedor,0)+isnull(P.StockInicial,0)-isnull(S.Salida,0) SaldoFinal
From Productos P
Left outer join
(SELECT IDProducto,sum(Cantidad) as Salida
from DetalleVenta
Where fecha Between @FechaInicio and @FechaFin
Group by IdProducto) S
On P.Id = S.IdProducto
Left outer join
(SELECT IdProducto,sum(Cantidad) as Entrada
from DetalleCompra
Where fecha Between @FechaInicio and @FechaFin
Group by IdProducto) J
On P.Id = J.IdProducto
/*Aca de la devolucion de Clientes*/
Left outer join
(SELECT IDProducto,sum(Cantidad) as DevCliente
from DetalleDevolucion
Where fecha Between @FechaInicio and @FechaFin
Group by IdProducto) M
On P.Id = M.IdProducto
/*Aca de la devolucion de Proveedores*/
Left outer join
(SELECT IDProducto,sum(Cantidad) as DevProveedor
from DetalleDevolucionProveedores
Where fecha Between @FechaInicio and @FechaFin
Group by IdProducto) B
On P.Id = B.IdProducto
__________________
Soluciones basadas en .NET Framework y SQL Server