How to get array value from wordpress database get_results

Hi and welcome to stackoverflow

Your code must change to

function get_customer_gain() {
  global $wpdb; 
  $users = $wpdb->get_results( "SELECT SUM(wp_wpdatatable_1.payback) as sumed FROM wp_wpdatatable_1");
  foreach( $users as $user ) {
    echo $user->sumed;
  }
}
add_shortcode('customer_gain', 'get_customer_gain');

You have to use the correct syntax $wpdb->get_results( $query, $type_of_result);

check this out here

EDIT FOR EXPLAINATION:

$users = $wpdb->get_results( "SELECT SUM(wp_wpdatatable_1.payback) as sumed FROM wp_wpdatatable_1", ARRAY_A);

The array_a will retur associative array while by default it returns as object that cause problem