I'm only familiar with C++, Python, and SQL. Neither GDB nor PDB helps here, and I've never heard of a SQL debugger that will break apart expressions and let you view intermediate query results.
But you could in many cases easily infer from the execution plan what a query would look like and fetch an intermediate set separately.