0
SELECT
B.tblBooking_id,
F.M_Merged_CustomerId,
B.depart_date,
B.cancellation,
B.booking_num,
B.end_date,
B.date_booked,
B.booking_price,
B.tblBooking_Id as SOURCE_RES_ID ,
B.agentid,
B.is_insert_date,
B.is_update_date is_update_date,
A.Agent_Email_Address as agent_email,
A.Agent_Email_Address as agent_email_system
FROM tblBooking B 
JOIN tblAgent A 
ON B.agentid=A.agentid
LEFT JOIN  tblFactCustomers F
ON B.booking_num = F.raw_booking_num
WHERE B.agentid !=0 or B.agentid IS NOT  NULL
GROUP BY B.tblBooking_id;

Table used : tblBooking , tblAgent , tblFactCustomers Index are present in booking num and raw booking num

1 Answers1

0

I doubt that script will execute successfully as there's group by clause and no aggregate function used. However for performance measures please check the field value B.agentID and if there's no value in negative then replace WHERE B.agentid !=0 or B.agentid IS NOT NULL with WHERE B.agentid >0 and create a non clustered index on agentID.

Mr. K
  • 380
  • 3
  • 15