Just an observation, but you may get a better quality response if you post a screen shot of your domain model. Also to echo Eric’s comment , please describe the business problem you are trying to solve. There may be another way to model it that is better suited to Mendix’s capabilities.
I think the error you are getting is because you are doing the retrieve in a nanoflow. Nanoflow’s do not yet have all the capabilities of Microflows, which is frustrating, but that’s where we are. The nanoflows are running against the database on your device, not vs. the database on the server. That imposes some limitations.
Have you tried performing your retrieve in a microflow instead? If you are naturally happier with SQL, then you may even want to run it as an OQL query so you can freely join as deeply as you want.
Once your microflow works, you can call it from your nanoflow – there are restrictions on how you do that, but we can address those once your query is running.