on 11-03-2015 9:21 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI
This query should work
select (SELECT count(T0.[CardCode]) FROM OCRD T0 WHERE T0.[QryGroup17] ='y' and T0.[validFor] ='y') as MMSProfessionalCustomers
SELECT count (distinct T0.[CardCode]) FROM OCRD T0 WHERE T0.[QryGroup15] ='y' and T0.[validFor] ='y' ) as MMSCommunityCustomers
SELECT count (distinct T0.[CardCode]) FROM OCRD T0 WHERE T0.[QryGroup17] ='y' and T0.[validFor] ='y') as MMSProfessionalCustomers
shachar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
108 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.