Is it possible to show tag history binding underlying SQL?

If you get stuck with something odd, look at the view() function in my Simulation Aids module. It is a binding expression function that processes datasets into new datasets, with filtering, grouping, pivoting, and ordering. It uses python under the hood, and in debug mode, will show you the python it created from your pseudo-SQL.