I have the following SQL query and php output being run on a mysql database...
$count0 = $wpdb->get_results("
SELECT *
FROM
wp_rg_lead
INNER JOIN wp_rg_lead_detail ON
wp_rg_lead.id=wp_rg_lead_detail.lead_id
WHERE wp_rg_lead.form_id = '46'
AND cast(date_created as date) >= current_date - interval '7' day
AND field_number = '18'
ORDER BY value
");
foreach ( $count0 as $page ) {
echo $repid_field . ' - ' . $page->form_id . ' - ' . $page->value . ' - ' . $page->lead_id . ' - ' . $page->date_created.'<br/>';
}
This works great but I want to add a count to it so that when it outputs the line it tells me how many of 'value' exists.
I have had a look at the COUNT function but I am not sure where to add it in