以下代码来自MS Access,我正在尝试将其转换为nad使其在SQL Server中正常工作。我不知道如何转换包含IsNull的最后一行。 P.S: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));
答案 0 :(得分: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;