Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Union three queries to show all results

Hi

I have three queries that i'd like to package into one so that each result is displayed in a separate column. Any help would be much appreciated.

Separate queries are below

SELECT count (distinct T0.[CardCode])[MMS Professional Customers] FROM OCRD T0 WHERE T0.[QryGroup17] ='y'  and T0.[validFor] ='y'

SELECT count (distinct T0.[CardCode])[MMS Community Customers] FROM OCRD T0 WHERE T0.[QryGroup15] ='y'  and T0.[validFor] ='y'

SELECT count (distinct T0.[CardCode])[MMS Professional Customers] FROM OCRD T0 WHERE T0.[QryGroup17] ='y'  and T0.[validFor] ='y'

Cheers

Lisa

Former Member
replied

Hi Lisa,

Please try this:

SELECT (SELECT count (distinct T0.[CardCode])[MMS Professional Customers] FROM OCRD T0 WHERE T0.[QryGroup17] ='y'  and T0.[validFor] ='y') AS Column1

,(SELECT count (distinct T0.[CardCode])[MMS Community Customers] FROM OCRD T0 WHERE T0.[QryGroup15] ='y'  and T0.[validFor] ='y') AS Column2

,(SELECT count (distinct T0.[CardCode])[MMS Professional Customers] FROM OCRD T0 WHERE T0.[QryGroup17] ='y'  and T0.[validFor] ='y') AS Column3

Of course you can rename the columns to something a little more descriptive.

Regards,

Johan

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question