Trouble with BAQ markup

,

I have a BAQ like this:

 
select 
	[OrderHed].[OrderNum] as [OrderHed_OrderNum],
	(convert(varchar, OrderHed.OrderNum) +' and  ' + LEFT(LEFT(REPLACE(REPLACE(((select 
	(CAST(OrderHed1.OrderNum AS VARCHAR) + ', ') as [Calculated_Orders]
from Erp.OrderHed as OrderHed1
where (OrderHed1.OpenOrder <> 0  and OrderHed1.ShortChar02 = convert(varchar, OrderHed.OrderNum)  and OrderHed1.CustNum = OrderHed.CustNum FOR XML PATH('')))) , '</Calculated_Orders>',''),'<Calculated_Orders>',''), LEN(REPLACE(REPLACE(((select 
	(CAST(OrderHed1.OrderNum AS VARCHAR) + ', ') as [Calculated_Orders]
from Erp.OrderHed as OrderHed1
where (OrderHed1.OpenOrder <> 0  and OrderHed1.ShortChar02 = convert(varchar, OrderHed.OrderNum)  and OrderHed1.CustNum = OrderHed.CustNum FOR XML PATH('')))) , '</Calculated_Orders>',''),'<Calculated_Orders>',''))-1),100)) as [Calculated_AllOrders]
from Erp.OrderHed as OrderHed
where (OrderHed.ShipToNum = '[EpiBinding:OrderHed.ShipToNum]'  and OrderHed.OpenOrder <> 0  and OrderHed.ShortChar02 = '')

And it works perfectly. I want to add another BAqMarkup criteria OrderHed.OrderNum <> [EpiBinding:OrderHed.OrderNum] but the two ways I have tried haven’t worked.

where (OrderHed.ShipToNum = '[EpiBinding:OrderHed.ShipToNum]'  and OrderHed.OrderNum <> [EpiBinding:OrderHed.OrderNum]  and OrderHed.OpenOrder <> 0  and OrderHed.ShortChar02 = '')

Gives the error “Invalid column name 'EpiBinding:OrderHed.OrderNum’.” if I use the Constant option and “Incorrect syntax near ‘<’.” if I use the expression option. I tried converting it just in case:

where (OrderHed.ShipToNum = '[EpiBinding:OrderHed.ShipToNum]'  and OrderHed.OrderNum <> convert(int, '[EpiBinding:OrderHed.OrderNum]')  and OrderHed.OpenOrder <> 0  and OrderHed.ShortChar02 = '')

Which gives no syntax error, but also does not work correctly (I don’t think its replaced with the actual binding value, it just tries to convert the text.

There is some other part of the BAQ that is messing it up somehow, if I remove the xml stuff for concatenating I can use OrderHed.OrderNum <> [EpiBinding:OrderHed.OrderNum] without issues.

Any BAQ Markup experts here?