I am trying to build a shortcode that will query a db and sum. Here is what I have so far:
function my_plugin_name_count_people() {
global $wpdb;
return $wpdb->query ("SELECT COALESCE(SUM(`column_one`), column_two ,0) FROM `table_name` WHERE `booking_date` = CURDATE() -10");
}
add_shortcode('countpeople', 'my_plugin_name_count_people');
This returns '1' as the value but if I run the statement in myphpadmin then it shows NULL. That is accurate since there are no results for that day. Anyone know why it is showing '1' on the SUM() count?