I want to get number or count of same meta_value of meta_key == 'parent_id'.How can i get it? What should be the wordpress query for counting records in same table?
//set the meta_key to the appropriate custom field meta key
$meta_key = 'parent_id';
$allmiles = $wpdb->get_var( $wpdb->prepare(
"SELECT meta_value,
SUM(IF(meta_value = "Purva", 1,0)) AS 'parent_id',
COUNT(meta_value) AS 'total'
FROM $wpdb->wp_postmeta
GROUP BY post_id
ORDER BY parent_id DESC",
$meta_key
) );
echo "<p>Total miles is {$allmiles}</p>";