cancel
Showing results for 
Search instead for 
Did you mean: 

Respaldar los Query Manager

Former Member
0 Kudos

          HOLA NECESITO RESPALDAR TODAS LAS CONSULTAS GRABADAS EN EL QUERY MANAGER,

CUAL ES LA TABLA O EN DONDE ESTA ALMACENADO

MIL GRACIAS

Accepted Solutions (1)

Accepted Solutions (1)

former_member211460
Participant
0 Kudos

En la tabla OUQR

Saludos

Former Member
0 Kudos

MIL GRACIAS

Former Member
0 Kudos

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

Answers (0)