cancel
Showing results for 
Search instead for 
Did you mean: 

Ayuda reporte

Former Member
0 Kudos

Jovenes tengo un query que desde el sql server si mi funciona perfectamente pero cuando lo quiero pasar al query manager y utilizo [%0] y el [%1] me da error el sistemas y no se que sea adjutno una imagen del error que da y les dejo el query que quiero ejecutar.

Query


SELECT DISTINCT

'orden_de_venta' as tipo,  t2.cardcode as codigo, t2.cardname as Cliente, t2.DocNum AS Orden_de_venta, t2.doctotal as Total_Orden,

                 t2.DocDate [Fecha_Creacion_Orden], t2.DocTime[Hora_Creacion_Orden],  sum(T8.Weight1)[Peso_Orde_Venta],

'Entregas' as Tipo, t4.DocNum AS No_Entrega, t4.doctotal as totalentrega, t4.DocDate [Fecha_Creacion_Entrega], t4.doctime[Hora_Creacion_Entrega],

                 sum(T3.Weight1) [Peso_Entregas],

'factura_normal' as tipo,  /*t5.cardcode as codigo, t5.cardname as Cliente,*/ t5.DocNum AS No_Fact,

                t5.doctotal as Total_fact, t5.DocDate [Fecha_Creacion_Factura], t5.DocTime[Hora_Creacio_ Factura],

                sum(t6.Weight1)[Peso_Facturas_Normal],

               

'Factura Reserva' as Tipo,/*

                Case When t5.ObjType = '13' Then T5.CardCode Else '' End [Codigo],

                Case When t5.ObjType = '13' Then T5.CardName Else '' End [Cliente],*/

                Case When t5.ObjType = '13' Then T5.DocDate Else '' End [Fecha_Creacion_Factura_Reserva],

                Case When t5.ObjType = '13' Then t5.DocTime Else '' End [Hora_Creacion_Factura_Reserva],

                Case When t5.ObjType = '13' Then T5.DocNum Else '' End [No._Factura_Reserva],

                Case When t5.ObjType = '13' Then T5.DocTotal Else '' End [Total_Factura_Reserva],

                Case When t5.ObjType = '13' Then sum(T8.Weight1) Else '' End [Peso_Factura_Reserva],   

'Notas de Credito' as Tipo, T0.DocDate [Fecha Creacion_Nota_Credito], T0.DocTime[Hora_Creacion_Nota_Credito],

                t0.DocNum AS Nota_credito, T0.DocTotal[Total_Notas_Credito], sum(T1.Weight1)[LB_Notas_Credito]   

               

                FROM ORIN t0 INNER JOIN

                      RIN1 t1 ON t0.DocEntry = t1.DocEntry RIGHT OUTER JOIN

                      ORDR t2 LEFT OUTER JOIN

                      DLN1 t3 INNER JOIN

                      ODLN t4 ON t3.DocEntry = t4.DocEntry INNER JOIN

                      OINV t5 INNER JOIN

                      INV1 t6 ON t5.DocEntry = t6.DocEntry ON t4.DocEntry = t6.BaseEntry ON

                                 t2.DocEntry = t3.BaseEntry ON t1.BaseEntry = t5.DocNum LEFT OUTER JOIN

                      [DBO].[_SBOV_ORDEN_DE_VENTA] T7 ON T0.DocEntry = T7.[# Doc] INNER JOIN

                      RDR1 T8 ON t2.DocEntry = T8.DocEntry

where t5.isins='N' and t2.DocDate>= [%0] and t2.DocDate<= [%1]

Group By t2.cardcode, t2.cardname,t2.DocNum, t2.doctotal, t2.DocDate , t4.DocNum, t4.doctotal, t4.DocDate, t5.DocNum,

         t5.doctotal, t5.DocDate, t0.DocNum, T0.DocDate, T0.DocTotal, t2.cardcode, t2.cardname, t2.DocNum,

         t2.doctotal, t2.DocDate, t5.ObjType, T5.CardCode, T5.CardName, T5.DocNum,  T5.DocDate,

         t5.DocTotal, t2.DocTime, t4.doctime, t5.DocTime, T0.DocTime

Espero me puedas ayudar ya probe colocar comillas simples en los atributos pero no funciona tampoco '[%0]' espero me puedas ayudar e indicarme en donde esta mi error

Por su tiempo y ayuda muy agradecido

Saludos cordiales

Accepted Solutions (1)

Accepted Solutions (1)

felipe_loyolarodriguez
Active Contributor
0 Kudos

Buenas

Prueba lo siguiente


declare @f1 datetime

declare @f2 datetime

set @f1 = (/*select top 1 A.TransId from OINV A where A.DocDate>=*/'[%0]')

set @f2 = (/*select top 1 A.TransId from OINV A where A.DocDate<=*/'[%1]')

   

SELECT DISTINCT  

    'orden_de_venta' as tipo,  t2.cardcode as codigo, t2.cardname as Cliente, t2.DocNum AS Orden_de_venta, t2.doctotal as Total_Orden,  

                     t2.DocDate [Fecha_Creacion_Orden], t2.DocTime[Hora_Creacion_Orden],  sum(T8.Weight1)[Peso_Orde_Venta], 

    'Entregas' as Tipo, t4.DocNum AS No_Entrega, t4.doctotal as totalentrega, t4.DocDate [Fecha_Creacion_Entrega], t4.doctime[Hora_Creacion_Entrega], 

                     sum(T3.Weight1) [Peso_Entregas],  

    'factura_normal' as tipo,  /*t5.cardcode as codigo, t5.cardname as Cliente,*/ t5.DocNum AS No_Fact,  

                    t5.doctotal as Total_fact, t5.DocDate [Fecha_Creacion_Factura], t5.DocTime[Hora_Creacio_ Factura],  

                    sum(t6.Weight1)[Peso_Facturas_Normal], 

                     

    'Factura Reserva' as Tipo,/*  

                    Case When t5.ObjType = '13' Then T5.CardCode Else '' End [Codigo], 

                    Case When t5.ObjType = '13' Then T5.CardName Else '' End [Cliente],*/ 

                    Case When t5.ObjType = '13' Then T5.DocDate Else '' End [Fecha_Creacion_Factura_Reserva], 

                    Case When t5.ObjType = '13' Then t5.DocTime Else '' End [Hora_Creacion_Factura_Reserva], 

                    Case When t5.ObjType = '13' Then T5.DocNum Else '' End [No._Factura_Reserva], 

                    Case When t5.ObjType = '13' Then T5.DocTotal Else '' End [Total_Factura_Reserva], 

                    Case When t5.ObjType = '13' Then sum(T8.Weight1) Else '' End [Peso_Factura_Reserva],     

    'Notas de Credito' as Tipo, T0.DocDate [Fecha Creacion_Nota_Credito], T0.DocTime[Hora_Creacion_Nota_Credito], 

                    t0.DocNum AS Nota_credito, T0.DocTotal[Total_Notas_Credito], sum(T1.Weight1)[LB_Notas_Credito]     

                     

                    FROM ORIN t0 INNER JOIN 

                          RIN1 t1 ON t0.DocEntry = t1.DocEntry RIGHT OUTER JOIN 

                          ORDR t2 LEFT OUTER JOIN 

                          DLN1 t3 INNER JOIN 

                          ODLN t4 ON t3.DocEntry = t4.DocEntry INNER JOIN 

                          OINV t5 INNER JOIN 

                          INV1 t6 ON t5.DocEntry = t6.DocEntry ON t4.DocEntry = t6.BaseEntry ON  

                                     t2.DocEntry = t3.BaseEntry ON t1.BaseEntry = t5.DocNum LEFT OUTER JOIN 

                          [DBO].[_SBOV_ORDEN_DE_VENTA] T7 ON T0.DocEntry = T7.[# Doc] INNER JOIN  

                          RDR1 T8 ON t2.DocEntry = T8.DocEntry 

    where t5.isins='N' and t2.DocDate>= @f1 and t2.DocDate<= @f2

    Group By t2.cardcode, t2.cardname,t2.DocNum, t2.doctotal, t2.DocDate , t4.DocNum, t4.doctotal, t4.DocDate, t5.DocNum,  

             t5.doctotal, t5.DocDate, t0.DocNum, T0.DocDate, T0.DocTotal, t2.cardcode, t2.cardname, t2.DocNum,  

             t2.doctotal, t2.DocDate, t5.ObjType, T5.CardCode, T5.CardName, T5.DocNum,  T5.DocDate, 

             t5.DocTotal, t2.DocTime, t4.doctime, t5.DocTime, T0.DocTime 

Saludos

Former Member
0 Kudos

Gracias Felipe por tu pronta respuesta, ya lo ejecute como lo indicas pero sigue dandome el mismo error, por si tuvieras otra opcion te lo agradeceria bastante.

Saludos

felipe_loyolarodriguez
Active Contributor
0 Kudos

OK

Cambia los set por lo siguiente


set @f1 = (/*select top 1 A.TransId from [dbo].[OINV] A where A.DocDate>=*/'[%0]')

set @f2 = (/*select top 1 A.TransId from [dbo].[OINV] A where A.DocDate<=*/'[%1]')

Atte.

Former Member
0 Kudos

Gracias Felipe por tu ayuda ahi quedo perfecto, muy agradecido por tu ayuda.

Saludos Cordiales

Answers (0)