I was getting this too. Looks like someone meant to put in a SORT BY based on the LISTING variable passed in the URL, but I never found any code to cover it. So, in /admin/orders.php, find this line, near the top:
$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
Above that, add:
if($HTTP_GET_VARS['listing']=="customers") { $sort_by = "o.customers_name"; }
elseif($HTTP_GET_VARS['listing']=="customers-desc") { $sort_by = "o.customers_name DESC"; }
elseif($HTTP_GET_VARS['listing']=="ottotal") { $sort_by = "order_total"; }
elseif($HTTP_GET_VARS['listing']=="ottotal-desc") { $sort_by = "order_total DESC"; }
elseif($HTTP_GET_VARS['listing']=="id-asc") { $sort_by = "o.orders_id"; }
elseif($HTTP_GET_VARS['listing']=="id-desc") { $sort_by = "o.orders_id DESC"; }
elseif($HTTP_GET_VARS['listing']=="status-asc") { $sort_by = "o.orders_status"; }
elseif($HTTP_GET_VARS['listing']=="status-desc") { $sort_by = "o.orders_status DESC"; }
else { $sort_by = "o.orders_id DESC"; }
Then, go way down and find the block that starts:
if (isset($HTTP_GET_VARS['cID'])) {
$cID = tep_db_prepare_input($HTTP_GET_VARS['cID']);
$orders_query_raw = "select o.orders_id, .................
Change all three instances of:
order by $orders";
to
order by " . $sort_by;
Works for me.