Ver Mensaje Individual
  #2  
Antiguo 17-11-2018
Avatar de Casimiro Notevi
Casimiro Notevi Casimiro Notevi is offline
Moderador
 
Registrado: sep 2004
Ubicación: En algún lugar.
Posts: 32.257
Reputación: 10
Casimiro Notevi Tiene un aura espectacularCasimiro Notevi Tiene un aura espectacular
Si es una sola tabla, quita todo lo de FAC_CREDITO.
Código SQL [-]
select
ID_CLIENTE,
ID_FACTURA,
IIF( DATEDIFF( month, current_date, date FECHAFIN_CRE ) <0 AND (FECHAFIN_CRE <> '0000-00-00' ), M_VENTACREDITO,0) AS POR_VENCER,
IIF( DATEDIFF( month, current_date, date FECHAFIN_CRE )>=0 AND DATEDIFF( month, current_date, date FECHAFIN_CRE  ) <=15 OR FECHAFIN_CRE = '00-00-0000', M_VENTACREDITO,0) AS VENCIDOS115, 
IIF( DATEDIFF( month, current_date, date FECHAFIN_CRE )>=16 AND DATEDIFF( month, current_date, date FECHAFIN_CRE ) <=30, M_VENTACREDITO,0) AS VENCIDOS1630,
IIF( DATEDIFF( month, current_date, date FECHAFIN_CRE )>=31 AND DATEDIFF( month, current_date, date FECHAFIN_CRE ) <=45, M_VENTACREDITO,0) AS VENCIDOS3145,
IIF( DATEDIFF( month, current_date, date FECHAFIN_CRE )>=46 AND DATEDIFF( month, current_date, date FECHAFIN_CRE ) <=60, M_VENTACREDITO,0) AS VENCIDOS4660,
IIF( DATEDIFF( month, current_date, date FECHAFIN_CRE )>=61 AND DATEDIFF( month, current_date, date FECHAFIN_CRE ) <=90, M_VENTACREDITO,0) AS VENCIDOS6190,
IIF( DATEDIFF( month, current_date, date FECHAFIN_CRE )>=91 AND DATEDIFF( month, current_date, date FECHAFIN_CRE ) <=120, M_VENTACREDITO,0) AS VENCIDOS91120,
IIF( DATEDIFF( month, current_date, date FECHAFIN_CRE )>=121 ,M_VENTACREDITO,0) AS VENCIDOSMAS120
from FAC_CREDITO
ORDER BY ID_CLIENTE

Responder Con Cita