LASTCHILD

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.

Syntax:

SUM ( LastChild ( aggExp, childDIm ))

Example:

select customerid, year(orderdate) as theyear, 
month(orderdate) as theMonth,
sum(lastchild(freight, orderdate )) as [lastchild]
from orders
group by customerid,year(orderdate),month(orderdate)
order by customerid, year(orderdate),month(orderdate)
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.