Dest
Oct 4th, 2000, 11:40 AM
I'm in the process of converting an Access DB over to SQL / VB and I need a little help with a couple query's I have..
This one (for example) has 2 parts.. Part A Query's 2 tables based on criteria and pulls out 2 fields from that...
Part B Query's Part A to get a count of one of the rows (variation in another example is the sum of one of the rows)
How can I combine this into 1 Query... Transact-SQL is fine..
HERE is my 2 query's
QUERY A)
SELECT DISTINCT dbo_PROJ_INFO.REGION_CODE, dbo_EVENT_PART.COMPANY_ID
FROM dbo_EVENT_PART INNER JOIN dbo_PROJ_INFO ON dbo_EVENT_PART.PROJECT_KEY = dbo_PROJ_INFO.UNIQUE_KEY
WHERE (((dbo_EVENT_PART.ATTENDED)="Y") AND ((dbo_PROJ_INFO.EV_CANCELLED)="N") AND ((dbo_PROJ_INFO.END_DATE) Between #8/1/2000# And #8/31/2000#));
QUERY B)
SELECT [RO MTrak Report - Event Companies Distinct].REGION_CODE, Count([RO MTrak Report - Event Companies Distinct].COMPANY_ID) AS CountOfCOMPANY_ID
FROM [RO MTrak Report - Event Companies Distinct]
GROUP BY [RO MTrak Report - Event Companies Distinct].REGION_CODE;
This one (for example) has 2 parts.. Part A Query's 2 tables based on criteria and pulls out 2 fields from that...
Part B Query's Part A to get a count of one of the rows (variation in another example is the sum of one of the rows)
How can I combine this into 1 Query... Transact-SQL is fine..
HERE is my 2 query's
QUERY A)
SELECT DISTINCT dbo_PROJ_INFO.REGION_CODE, dbo_EVENT_PART.COMPANY_ID
FROM dbo_EVENT_PART INNER JOIN dbo_PROJ_INFO ON dbo_EVENT_PART.PROJECT_KEY = dbo_PROJ_INFO.UNIQUE_KEY
WHERE (((dbo_EVENT_PART.ATTENDED)="Y") AND ((dbo_PROJ_INFO.EV_CANCELLED)="N") AND ((dbo_PROJ_INFO.END_DATE) Between #8/1/2000# And #8/31/2000#));
QUERY B)
SELECT [RO MTrak Report - Event Companies Distinct].REGION_CODE, Count([RO MTrak Report - Event Companies Distinct].COMPANY_ID) AS CountOfCOMPANY_ID
FROM [RO MTrak Report - Event Companies Distinct]
GROUP BY [RO MTrak Report - Event Companies Distinct].REGION_CODE;