fixed the nvl bug in aggregation