我运行以下查询:
SELECT [LISTING_ID] ,[COMPANY_NM]
FROM [InterAction_Test].[dbo].[INT_AUX_LISTING]
WHERE COMPANY_NM = 'IB Sample 12'
回报:
LISTING_ID COMPANY_NM
---------- ----------
335698 IB Sample 12
然后:
SELECT [LIST1_ID],[LIST2_ID],[CORRELATION_TYP_ID]
FROM [InterAction_Test].[dbo].[INT_AUX_LIST_LIST]
WHERE LIST1_ID = 335698
回报:
LIST1_ID LIST2_ID CORRELATION_TYP_ID
-------- -------- ------------------
335698 139685 90
335698 139685 10003
335698 139685 10009
然后:
SELECT [LISTING_ID],[DISPLAY_NM]
FROM [InterAction_Test].[dbo].[INT_AUX_LISTING]
WHERE LISTING_ID = 139685
回报:
LISTING_ID DISPLAY_NM
---------- ----------
139685 Swisk, Bob
然后我运行:
SELECT dbo.INT_AUX_LISTING.COMPANY_NM, INT_AUX_LISTING_1.DISPLAY_NM AS [Relationship Partner],
INT_AUX_LISTING_2.DISPLAY_NM AS [Introducing Partner], INT_AUX_LISTING_3.DISPLAY_NM AS [Introduced By]
FROM dbo.INT_AUX_LISTING
INNER JOIN dbo.INT_AUX_LIST_LIST ON dbo.INT_AUX_LISTING.COMPANY_LIST_ID = dbo.INT_AUX_LIST_LIST.LIST1_ID
INNER JOIN dbo.INT_AUX_LISTING AS INT_AUX_LISTING_1 ON dbo.INT_AUX_LIST_LIST.LIST2_ID = INT_AUX_LISTING_1.LISTING_ID
INNER JOIN dbo.INT_AUX_LIST_LIST AS INT_AUX_LIST_LIST_1 ON dbo.INT_AUX_LISTING.COMPANY_LIST_ID = INT_AUX_LIST_LIST_1.LIST1_ID
INNER JOIN dbo.INT_AUX_LISTING AS INT_AUX_LISTING_2 ON INT_AUX_LIST_LIST_1.LIST2_ID = INT_AUX_LISTING_2.LISTING_ID
INNER JOIN dbo.INT_AUX_LIST_LIST AS INT_AUX_LIST_LIST_2 ON dbo.INT_AUX_LISTING.COMPANY_LIST_ID = INT_AUX_LIST_LIST_2.LIST1_ID
INNER JOIN dbo.INT_AUX_LISTING AS INT_AUX_LISTING_3 ON INT_AUX_LIST_LIST_2.LIST2_ID = INT_AUX_LISTING_3.LISTING_ID
GROUP BY dbo.INT_AUX_LISTING.COMPANY_LIST_ID, dbo.INT_AUX_LISTING.COMPANY_NM, INT_AUX_LISTING_1.DISPLAY_NM, INT_AUX_LISTING_2.DISPLAY_NM, INT_AUX_LISTING_3.DISPLAY_NM, dbo.INT_AUX_LIST_LIST.CORRELATION_TYP_ID, INT_AUX_LIST_LIST_1.CORRELATION_TYP_ID, INT_AUX_LIST_LIST_2.CORRELATION_TYP_ID
HAVING (dbo.INT_AUX_LIST_LIST.CORRELATION_TYP_ID = 90) AND (INT_AUX_LIST_LIST_1.CORRELATION_TYP_ID = 10003) AND (INT_AUX_LIST_LIST_2.CORRELATION_TYP_ID = 10009)
当我希望它返回时,这不会返回任何行:
COMPANY_NM Relationship Partner Introducing Partner Introduced By
---------- -------------------- ------------------- -------------
IB Sample 12 Swisk, Bob Swisk, Bob Swisk, Bob
我究竟做错了什么?