text TO lcSQL TEXTMERGE NOSHOW PRETEXT 7 trans.*, ; Trans_Employees_Queues.* ; from trans INNER join Trans_Employees_Queues ; on trans.cTrans_pk = Trans_Employees_Queues.cTrans_fk ; <<m.tcJoin>> ; where trans.cDepartment_Code like '<<this.cDepartment_code>>' ; and trans.cResolution_Codes_fk is NULL ENDTEXT lcSQL = "SELECT " + IIF(not EMPTY(m.tnTotalNumber), ; "TOP " + TRANSFORM(m.tnTotalNumber)+ " ","") + ; m.lcSQL + iif(not empty(m.tcWhere), ; " AND " + m.tcWhere,"") + ; " order by trans.tDate_Received"However, there is a problem. There could be records in Trans_Employees_Queues for "FORCED" queue. In other words, for these cases we create additional records in Trans_Employees_Queues table and then use Employee_Queue_Schedules table to assign them. Now, obviously I do not want to assign records which are already in the FORCED queue. Do you see a way to amend this query?