Thanks for both answers! "But the solution is pretty simple, use a inner sql query and not a table to select from" I did that once by accident in another SQL and wondered why it worked and the correct method didn't. I will now try it using field alias because the final SQL is fairly complex and it will be much more understandable that way.