The following code is from MS Access, and I am trying to convert it nad make it works in SQL server. I dont know how to convert the last line, which contains IsNull. PS:LIS is a name of drive. Thanks for anyone who can give me hints.
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));
Only a couple of minor issues, however you could improve this query's readability greatly by making proper use of table aliases. Please try this re-write:
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.