Hola amigos buen día, acudo a ustedes ya que tengo un detalle:
Tengo el siguiente Query de Antigüedad por tramos pero me gustaría que me trajera una linea adicional que es la de Abono a futuro esta es la que trae la antigüedad de saldos nativa de SAP. Sera que me podrían orientar ya que no he podido lograrlo.
SELECT
T2."CardCode" AS "Cliente",T2."RangeOfDaysOutStanding" AS "Rango",
IFNULL(T3."OverdueLC",0) AS "Saldo (ML)"
FROM ((select "RangeOfDaysOutStanding", "CardCode" from (select '0-30' as "RangeOfDaysOutStanding"
FROM DUMMY union all select '31-60' as "RangeOfDaysOutStanding" from DUMMY union all select '61-90' as "RangeOfDaysOutStanding" from DUMMY union all select '91-120' as "RangeOfDaysOutStanding"
FROM DUMMY union all select '>120' as "RangeOfDaysOutStanding" from DUMMY) T0 cross join (select "CardCode" as "CardCode"
FROM OCRD where "CardType" = 'C') T1) T2
LEFT JOIN (SELECT "BusinessPartnerCode", sum("OverdueLC") AS "OverdueLC", "AgingBucket"
FROM "_SYS_BIC"."sap.sbonavprod.ar.case/CustomerReceivableAgingQuery" ('PLACEHOLDER' = ('$$P_AgingBucketSize$$', '30')) GROUP BY "BusinessPartnerCode", "AgingBucket") T3 ON T2."RangeOfDaysOutStanding" = (CASE WHEN T3."AgingBucket" = '120+' THEN '>120' ELSE T3."AgingBucket" END) AND T2."CardCode" = T3."BusinessPartnerCode")
ORDER BY T2."CardCode", T2."RangeOfDaysOutStanding"
Saludos!