0

以下代码来自 MS Access,我正在尝试对其进行转换并使其在 SQL Server 中工作。我不知道如何转换包含 IsNull 的最后一行。PS:LIS是驱动器的名称。感谢任何可以给我提示的人。

SELECT DISTINCT [Molecular Pathology].[ID#], [Molecular Pathology].[Last Name], 
[Molecular Pathology].[First Name], [Molecular Pathology].Gender, 
[Molecular Pathology].[Date of Birth], [Molecular Tests].[Test Type], 
[Molecular Pathology].[Testing Gene], [Molecular Pathology].[Testing Exon], 
[Molecular Pathology].[Tested Mutation], [Molecular Pathology].[Testing Gene 2], 
[Molecular Pathology].[Testing Exon 2], [Molecular Pathology].[Tested Mutation 2], 
[Molecular Tests].[Test Name], [Molecular Pathology].[Result Reported],
[Molecular Pathology].[Date Received], [Molecular Pathology].[gp#]
FROM ([Molecular Pathology] 
LEFT JOIN [Molecular Select Tests] 
  ON [Molecular Pathology].ID = [Molecular Select Tests].ForKey) 
LEFT JOIN [Molecular Tests] 
  ON [Molecular Select Tests].Test = [Molecular Tests].[Test Name]
WHERE ((IsNull([Molecular Pathology].[LIS SignOut])<>False));
4

1 回答 1

1

只有几个小问题,但是您可以通过正确使用表别名来大大提高此查询的可读性。请尝试重新编写:

SELECT DISTINCT 
  mp.[ID#],            mp.[Last Name],       mp.[First Name], 
  mp.Gender,           mp.[Date of Birth],   mt.[Test Type],       
  mp.[Testing Gene],   mp.[Testing Exon],    mp.[Tested Mutation], 
  mp.[Testing Gene 2], mp.[Testing Exon 2],  mp.[Tested Mutation 2], 
  mt.[Test Name],      mp.[Result Reported], mp.[Date Received],
  mp.[gp#]
FROM 
  dbo.[Molecular Pathology] AS mp 
LEFT OUTER JOIN 
  dbo.[Molecular Select Tests] AS mst
  ON mp.ID = mst.ForKey -- Molecular Pathology has an ID column and an ID# column? 
LEFT OUTER JOIN 
  dbo.[Molecular Tests] AS mt
  ON mst.Test = mt.[Test Name]
WHERE 
  mp.[LIS SignOut] IS NULL;
于 2012-05-23T13:40:55.407 回答