$count = Core::Models->resultset('Shipment')->search( undef, { prefetch => 'rma', select => { count => 'DISTINCT(me.id)' }, as => [ 'total_count' ], } )->get_column('total_count')->first();