You can simplify that by using $wpdb->get_var
.
$total = $wpdb->get_var( "SELECT COUNT( * ) AS total FROM tableA" );
echo "Total Records:" . $total;
However, the code you’ve got should work– either version of it. I tested both.
The only thing I notice is that the first version of the code should give you Array ( [0] => Array ( [total] => 2 ) )
. Where is cnt
coming from?