MIght be best to post your swql or even better- do it first in sql to confirm your compliant then try to translate to SWQL- I find this removes a lot of trouble where SWQL just doesn't Like my functions But the script is fine.
Rules to union data:
- Each query must have the same number of columns
- Each column must have compatible data types
- Column names for the final result set are taken from the first query
- ORDER BY and COMPUTE clauses can only be issued for the overall result set and not within each individual result set
- GROUP BY and HAVING clauses can only be issued for each individual result set and not for the overall result set
- use a NuLL for any columns needed so you have an equal number of columns in each section
http://www.mssqltips.com/sqlservertip/1387/joining-data-using-union-and-union-all-in-sql-server/