on 04-15-2010 5:24 PM
Hola a todos, tengo una duda en el siguiente query y no se por que no me esta dando el resultado.
SELECT Distinct
'Orden'=Case When T1.BaseType Is Not null Then T1.BaseRef Else T0.U_Orden End,T0.FolioNum Factura,T0.CardName ClientelFROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN NNM1 T2 ON T0.Series = T2.Series WHERE T0.CreateDate = [%1] and T0.Canceled='N' and T0.DocEntry NOT IN (Select BaseEntry FROM RIN1 WHERE BaseType != -1) and T2.SeriesName ='CCC'
Simple, el reporte muestra el Baseref de la factura, el caso es que en ocaciones se emiten facturas sin pasar por orden de venta o entregas, cuando se emite la factura directamente ( no existe el Baseref) por lo tanto debe tomar el valor del campo de usuario, pero no me lo toma, me arroja en "0" cero.
Algun Tip?
Gracias.
Alessandro.
Hola.
Intenta con este:
SELECT Distinct T0.DocDate, T0.DOcNum,
'Orden'=(Case When T1.BaseType Is NULL or T1.BaseType = -1 Then T0.U_Placa Else T1.BaseRef End),
T0.FolioNum Factura,T0.CardName Clientel
FROM OINV T0
INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN NNM1 T2 ON T0.Series = T2.Series
WHERE T0.CreateDate BETWEEN '[%0]' AND '[%1]' and T0.Canceled='N' and T0.DocEntry NOT IN (
Select BaseEntry FROM RIN1 WHERE BaseType != -1) and T2.SeriesName ='CCC'
Era cuestion de ajustar la validación del case para el BaseType.
Cambié la fecha por un rang de fechas y agregué los campos DocNum y DocDate sólo para veriricación.
Habría un detalle con las notas débito que pueden aparecer en esta consulta. Si necesita que no se muestren las puede filtrar por el DocSubTipe = 'DN'
Saludos.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.