select sctcdesc, scclccli, scclnomb, scclcanu,
sccltele, sccltelx, sccltfax,
scdcfnac, (year(today)-year(scdcfnac)),
( select sum(sctfimus) from sctfactu
where sctfofic = scclofic
and sctfccli = scclccli
and sctffdoc >= (extend(today) - 6 units month)
and sctffdoc <= (extend(today) + 1 units month)
and year(sctffdoc) = year(today)) compra,
( select MAX(sctffdoc) from sctfactu
where sctfofic = scclofic
and sctfccli = scclccli
and year(sctffdoc) = year(today) ) ufecha,
scclslcr, ccclicor1
from scmaecli, scdatcli, sctabcon, outer bsoft:cccli
where scclofic = scdcofic
and scclccli = scdcccli
and scdcfnac is not null
and month(scdcfnac) = MONTH(today)
and sctcgrup = 19
and sctcsubg > 0
and scclubic = sctcgrup*1000+sctcsubg
and cccliofic = scclofic
and cccliccli = scclccli
order by DAY(scdcfnac)