sql order fixes