What seems to be a problem?
>Here is my present code
>
>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?
>
>Thanks a lot in advance.
>
>In other words, I need the same query, but with
>
>and Trans.cTrans_fk not in (select cTrans_pk from Trans inner join Trans_Employees_Queues on ... inner join Employee_Queue_Schedules ...
>)
>
>
>But the inner select should satisfy the same conditions as my outer select...
--sb--