on 10-23-2014 10:37 PM
HOLA NECESITO RESPALDAR TODAS LAS CONSULTAS GRABADAS EN EL QUERY MANAGER,
CUAL ES LA TABLA O EN DONDE ESTA ALMACENADO
MIL GRACIAS
En la tabla OUQR
Saludos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
VICTOR UNA CONSULTA
HOLA TENGO EL SIGUIENTE QUERY PARA OBTENER EL QUERY COMPLETO DEL INFORME DE ANALISIS DE VENTAS X ARTICULOS PERO ME ARROJA DIFERENCIAS EN ALGUNOS ARTICULOS CUANDO ESTOS TIENEN DESCUENTOS, FACTURAS DE ANTICIPOS, O ESTAN ABIERTOS.
EN FIN CUADRA EN UN 80 %, NECESITO EL 100% ME PODRIAN AYUDAR POR FAVOR
SELECT ItemCode,
Sum(TotFac) - SUM(TotNC) as 'FacturadoNeto',
Sum(GBrutaFac)-SUM(GbrutaNC) as 'GBruta',
Round((Sum(GBrutaFac)-SUM(GbrutaNC))/case when (Sum(TotFac) - SUM(TotNC))= 0 then 1 else (Sum(TotFac) - SUM(TotNC)) end *100,2) as '% Margen'
FROM (
SELECT
ItemCode = T1.ItemCode,
Marca = (Select T2.FirmName from OMRC T2 JOIN OITM T3 on T2.FirmCode = T3.FirmCode where T3.ItemCode=T1.Itemcode),
TotFac = Sum(T1.Linetotal),
GBrutaFac = SUM(T1.GrssProfit),
TotNc= 0,
GbrutaNC = 0
FROM OINV T0 (NOLOCK) INNER JOIN INV1 T1 (NOLOCK) ON T0.DocEntry = T1.DocEntry
WHERE (T0.[DocDate] >='20140101' AND T0.[DocDate] <='20141231')
and T0.DocType = 'I' -- solo facturas por articulos
Group by T1.ItemCode
Union
SELECT
ItemCode = T1.ItemCode,
Marca = (Select T2.FirmName from OMRC T2 JOIN OITM T3 on T2.FirmCode = T3.FirmCode where T3.ItemCode=T1.Itemcode),
TotFac = 0,
GBrutaFac = 0,
TotNc= Sum(T1.LineTotal),
GbrutaNC = SUM(T1.GrssProfit)
FROM ORIN T0 (NOLOCK) INNER JOIN RIN1 T1 (NOLOCK) ON T0.DocEntry = T1.DocEntry
WHERE (T0.[DocDate] >='20140101' AND T0.[DocDate] <='20141231')
and T0.DocType = 'I' -- solo NC por articulos
Group by T1.ItemCode
Union
SELECT
ItemCode = T1.ItemCode,
Marca = (Select T2.FirmName from OMRC T2 JOIN OITM T3 on T2.FirmCode = T3.FirmCode where T3.ItemCode=T1.Itemcode),
TotFac = 0,
GBrutaFac = 0,
TotNc= Sum(T1.LineTotal),
GbrutaNC = SUM(T1.GrssProfit)
FROM ODPI T0 (NOLOCK) INNER JOIN DPI1 T1 (NOLOCK) ON T0.DocEntry = T1.DocEntry
WHERE (T0.[DocDate] >='20140101' AND T0.[DocDate] <='20141231')
and T0.DocType = 'I' -- solo Fact Anticipos por articulos
Group by T1.ItemCode
) T
Group by ItemCode, Marca
User | Count |
---|---|
103 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.