Sorting dataprovider by a max value from another table

I have a situation where I have a customer grid, and in that grid there is a column for last call date. This is composed on fly and it’s the MAX from a call log table.

Now the questions is, how do I make this sortable. I am using dataProvider.

Please take a look at this wiki.

Replace ‘count(*)’ with ‘max(last_call)’, then you’ll get it, I hope. :)