Easy way to write complex queries in wordpress

I wouldn’t say it’s “easy”, but any complex queries like the one you have that can’t be handled via the API, WP_Query, or its filters should use the wpdb class.

global $wpdb;

$rows = $wpdb->get_results(
    "
    SELECT  p1.meta_value as avg,
            p2.meta_value as total,
            p1.meta_value * p2.meta_value as product
    FROM    $wpdb->postmeta as p1,
            $wpdb->postmeta as p2
    WHERE   p1.meta_key = 'crfp-average-rating'
            AND p2.meta_key = 'crfp-total-ratings'
            AND p1.post_id = p2.post_id
    "
);

foreach( $rows as $row ){
    print_r( $row );
}