I'm trying to use a Left Join to a subquery in Access 2003 and it isn't working as expected. When I run the subquery by itself it returns the expected results. Here's the subquery:
But when I try to left join this to a table it doesn't return the Name, Tube, Level, ID or Location fields:
I need it to return a result even if CTTest_TEST_MASTER.TestNumber is null, but if I add a Where clause like
at the end it returns nothing at all.
TESTSETUP_STAGING_INDIVIDUALTEST_INFO_FROM_LIS only has one row at any given time.
Can anyone tell me what I'm doing wrong here?
Code:
SELECT
'T0901' AS TestNumber
, NAME AS TestName
, TUBE AS SOFTTube
, '0901 -- ' & [ID] & ' / ' & [NAME] AS TestID
, IIf([LEVEL]='I',0,-1) AS GroupTestIndicator
, ID AS TestMnemonic
, LOCATION AS TestingLocationID
, 0 AS PerformingLabID
FROM TESTSETUP_STAGING_INDIVIDUALTEST_INFO_FROM_LIS
But when I try to left join this to a table it doesn't return the Name, Tube, Level, ID or Location fields:
Code:
SELECT DISTINCT
Q01.TestNumber
, Q01.TestName
, Q01.SOFTTube
, Q01.TestID
, Q01.GroupTestIndicator
, Q01.TestMnemonic
, Q01.TestingLocationID
, Q01.PerformingLabID
FROM (
SELECT
'T0901' AS TestNumber
, NAME AS TestName
, TUBE AS SOFTTube
, '0901 -- ' & [ID] & ' / ' & [NAME] AS TestID
, IIf([LEVEL]='I',0,-1) AS GroupTestIndicator
, ID AS TestMnemonic
, LOCATION AS TestingLocationID
, 0 AS PerformingLabID
FROM TESTSETUP_STAGING_INDIVIDUALTEST_INFO_FROM_LIS) AS Q01
LEFT JOIN CTTest_TEST_MASTER
ON Q01.TestNumber = CTTest_TEST_MASTER.TestNumber;
I need it to return a result even if CTTest_TEST_MASTER.TestNumber is null, but if I add a Where clause like
Code:
WHERE CTTest_TEST_MASTER.TestNumber Is Null
TESTSETUP_STAGING_INDIVIDUALTEST_INFO_FROM_LIS only has one row at any given time.
Can anyone tell me what I'm doing wrong here?