You just nailed it.
I had this query built in SQL Management Studio by using views. I could not get this to work in SWQL though.
Can you explain please how did you achieve this? What does A., S. mean in this case? Is it some sort of "variable" assigned to a table?