Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

All queries combined using a UNION, INTERSECT or EXCEPT

Simple Union query resulting in the error (All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.). I double checked the columns and everything looks good. What other reason(s) would cause this resulting error?

select OpportunityOwner, RecordType, ForecastCategory, CaseSafeOppID, date, [Fiscal Qtr], CloseDate,
MasterLicenseAmt, TrueMCVEst, MasterLicenseAmt + TrueMCVEst "Total $"
from ds_adhoc_sops.Pipe.DailyLicMCV

union

select OpportunityOwner, RecordType, ForecastCategory, CaseSafeOppID, date, [Fiscal Qtr], CloseDate
MasterLicenseAmt, TrueMCVEst, MasterLicenseAmt + TrueMCVEst "Total $"
from ds_adhoc_sops.Pipe.QTRLicMcvWL
;

Thank you

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You are missing a comma in the second part of the union statement, therefore the column size is different.

Try this:

select OpportunityOwner, RecordType, ForecastCategory, CaseSafeOppID, date, [Fiscal Qtr], CloseDate,
    MasterLicenseAmt, TrueMCVEst, MasterLicenseAmt + TrueMCVEst "Total $"
    from ds_adhoc_sops.Pipe.DailyLicMCV

union

select OpportunityOwner, RecordType, ForecastCategory, CaseSafeOppID, date, [Fiscal Qtr], CloseDate,
MasterLicenseAmt, TrueMCVEst, MasterLicenseAmt + TrueMCVEst "Total $"
from ds_adhoc_sops.Pipe.QTRLicMcvWL
;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading