Takes the parent SQL and adds the childDim to the grouping Clause, then returns the last entry ordered by childDim as an aggregation on aggExp. The resultset will not be expanded by the grouping level. It will only show the last entry from this additional query.
Ideal for working with snapshot data, e.g. inventory.
SUM ( LastChild ( aggExp, childDIm ))
select customerid, year(orderdate) as theyear,
month(orderdate) as theMonth,
sum(lastchild(freight, orderdate )) as [lastchild]
group by customerid,year(orderdate),month(orderdate)
order by customerid, year(orderdate),month(orderdate)
Please sign in to leave a comment.