this is more of a SQL stored proc that resides directly within the database itself. Have a look there. You should be able to call this stored proc from within Tableau.
Thanks Jeff. Its not setup as a stored proc just yet but i will see if the database guys can implement it. Thanks will be much more useful.
Tableau's Custom SQL needs to be a single SELECT statement that returns a single resultset.
In order to get what you have usable in Tableau you'd have to:
- Convert script variables into Tableau parameters (read here)
- Get rid of temp table creation (convert to subselect?)
Or as Jeff said - convert it to stored procedure (also with parameters).