on 10-04-2016 9:55 PM
Buenas tardes a todos, tengo un inconveniente al generar la siguiente consulta:
SELECT T0.[DocNum] AS 'No. O.V.', T0.[CANCELED], T0.[DocDate] AS 'Fecha O.V.', T0.[DocTotal]+ T0.[DiscSum]- T0.[VatSum] AS 'Valor O.V.',T0.[CardName], T1.[firstName] AS Titular, T2.[SlpName] AS 'Asesor Comercial' FROM ORDR T0 INNER JOIN OHEM T1 ON T0.[OwnerCode] = T1.[empID] INNER JOIN OSLP T2 ON T0.[SlpCode] = T2.[SlpCode] WHERE T1.[firstName] =[%0] AND T0.[DocDate] BETWEEN [%1] and [%2] OR T2.[SlpName] =[%3] ORDER BY T0.[DocDate]
Necesito agregarle 2 columnas mas, que serian No. de Oportunidad y Nombre de Oportunidad, que vienen de la tabla OOPR. No logro saber como vincular esta tabla a mi consulta.
Espero me puedan ayudar,
Muchas Gracias.
Hola esteban.
En la tabla OPR1 tendrás los campos DocId, ObjType y DocNumber, con ambos puedes enlazarte a la tabla ORDR pues tendrías en estricto orden: DocId = DocEntry, ObjType = 17 y DocNumber = DocNum.
Por favor verifica esta información ya que nunca he trabajado con oportunidades, lo anterior te lo informo tras una revisión a las tablas involucradas.
Saludos.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Aquí una prueba simple:
SELECT TY.OpprId, TY.NAME, T0.[DocNum] AS 'No. O.V.', T0.[CANCELED], T0.[DocDate] AS 'Fecha O.V.', T0.[DocTotal]+ T0.[DiscSum]- T0.[VatSum] AS 'Valor O.V.',T0.[CardName], T2.[SlpName] AS 'Asesor Comercial' FROM ORDR T0 INNER JOIN OSLP T2 ON T0.[SlpCode] = T2.[SlpCode]
Inner Join OPR1 TX ON TX.DocId = T0.DocEntry AND TX.ObjType = T0.ObjType AND TX.DocNumber = T0.DocNum INNER JOIN OOPR TY ON TY.[OpprId] = TY.[OpprId]
Quité algunas cosas de tu query para hacerlo rápido.
User | Count |
---|---|
108 | |
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.