Consider using my view() expression function to help you. You can compose your idea in Pseudo-SQL, then look at the python its debug mode displays for its solution to your problem. That python can be put in its own script module function and further optimized if you feel the need.
1 Like