Have you tried without using aliases? This here works for me:
ExecuteSQL ( "
PTO__Transactions AS T
T.amount IN ( SELECT DISTINCT ( amount ) FROM PTO__Transactions WHERE \"_kf_vorgangID\" = ?)
" ; "" ; "" ; PTO__Transactions::_kf_vorgangID
… but using T within the second SELECT also only yields a ?.
I think the inner SELECT opens a new scope in which your previously defined aliases are not recognized.
I tried it the way you suggest, and you are correct, the alias does not work withing the subquery, no alias is working in there even when defined within the subquery. I no longer get an error from the query but
I.c_SumOfValues IN (SELECT DISTINCT (c_SumOfValues) FROM SCLI___Cart WHERE FK_cartID = ?)";"";"";Cart::PK_CartID)
Just returns me the entire list of key in the table.
why not brreak it down in a Let statement to do two queries instead of one nested one? Should be a lot easier to troubleshoot
I can't mean what is DISTINCTed SumOfValues, but
I.PK_LineItemsID IN (SELECT MAX(PK_LineItemsID) FROM SCLI___Cart WHERE FK_cartID = ? GROUP BY c_SumOfValues)
MAX can be replaced with MIN for your purpose.
And may be same as simply
SELECT MAX(PK_LineItemsID) FROM SCLI___Cart WHERE FK_cartID = ? GROUP BY c_SumOfValues