woocommerce的最高报价

I'm trying to get the highest offer for a specific product. This is the postmeta of offer:

Array ( [0] => stdClass Object ( [meta_id] => 507752 [post_id] => 95953
 [5] => stdClass Object ( [meta_id] => 507757 [post_id] => 95953 [meta_key] => orig_offer_product_id [meta_value] => 2876 ) 
 [9] => stdClass Object ( [meta_id] => 507761 [post_id] => 95953 [meta_key] => orig_offer_amount [meta_value] => 1.00 ) 

I'm trying something like this:

echo $wpdb->get_var( "select max(orig_offer_amount->meta_value) 
from $wpdb->postmeta
where meta_value=2876 
 and meta_key='orig_offer_product_id' 
order by post_id limit 1" );

but it doesn't work.

Maybe some of you have the same situation. When I post some problem I have flash in my mind and I know how to solve the problem :) And there is the solution:

global $wpdb;
echo $wpdb->get_var( " select max(meta_value)
  from ".$wpdb->postmeta."
  where meta_key='orig_offer_amount'
    and meta_value!=''
    and post_id in(
      select p.post_id
      from ".$wpdb->postmeta." as p
      where p.meta_key='orig_offer_product_id' and
        p.meta_value=2876)" 
  );