Question about aggregation

I want to create two column aggregation type:

1.Average.

2.First/Last aggregation column ordered by another column and not by timestamp.

Is it possible? If yes, how?

Thanks,

Bar SHalev