删除选定数据集 (ADS) 中具有相同 ID 的记录

发布于 2024-09-24 09:06:15 字数 1251 浏览 0 评论 0原文

我正在尝试查询临床实践管理数据库以返回与四个不同字段的值列表(icd-9 代码)中的任何内容相匹配的数据集,但随后仅返回患者的 ID 号,或仅返回第一条记录对于具有 ICD-9 代码之一的患者。然后,我计划编造一些子报告,为我提供患者所需的其余数据,包括最后一个病例/就诊的 icd-9 代码。

该软件生成如下内容:

SELECT DISTINCT 
                MWTRN."Chart Number" AS Chart_Number, 
                MWTRN."Diagnosis Code 1" AS Diagnosis_Code_1, 
                MWTRN."Diagnosis Code 2" AS Diagnosis_Code_2, 
                MWTRN."Diagnosis Code 3" AS Diagnosis_Code_3, 
                MWTRN."Diagnosis Code 4" AS Diagnosis_Code_4, 
                MWTRN."Date From" AS Date_From, 
                MWTRN."Date To" AS Date_To, 
                MWPAT."First Name" AS First_Name, 
                MWPAT."Last Name" AS Last_Name
FROM MWTRN MWTRN, MWPAT MWPAT
WHERE 
      (MWPAT."Chart Number" = MWTRN."Chart Number")
GROUP BY MWTRN."Chart Number", 
         MWTRN."Diagnosis Code 1", 
         MWTRN."Diagnosis Code 2", 
         MWTRN."Diagnosis Code 3", 
         MWTRN."Diagnosis Code 4", 
         MWTRN."Date From", MWTRN."Date To", 
         MWPAT."Last Name", MWPAT."First Name"

生成数据集后,如何返回并对结果进行配对?

我读过几个支持广告的 SQL 教程网站来读取生成的 SQL,并认为我需要的是 DISTINCT,但这仅检查整个记录是否不同,而不仅仅是 ID。

-- 外行人使用 Advantage 数据库服务器和可能以某种方式与 Crystal Reports 关联的报告软件。

I'm trying to query a clinic practice management database to return a dataset that matches any in a list of values (icd-9 codes) for four different fields, but then only return the id number for the patient, or only the first record for that patient which has one of the icd-9 codes. Then, I plan to finagle some sub report to give me the rest of the data I need for the patient, including the icd-9 codes for the last case/visit.

The software generates something like the following:

SELECT DISTINCT 
                MWTRN."Chart Number" AS Chart_Number, 
                MWTRN."Diagnosis Code 1" AS Diagnosis_Code_1, 
                MWTRN."Diagnosis Code 2" AS Diagnosis_Code_2, 
                MWTRN."Diagnosis Code 3" AS Diagnosis_Code_3, 
                MWTRN."Diagnosis Code 4" AS Diagnosis_Code_4, 
                MWTRN."Date From" AS Date_From, 
                MWTRN."Date To" AS Date_To, 
                MWPAT."First Name" AS First_Name, 
                MWPAT."Last Name" AS Last_Name
FROM MWTRN MWTRN, MWPAT MWPAT
WHERE 
      (MWPAT."Chart Number" = MWTRN."Chart Number")
GROUP BY MWTRN."Chart Number", 
         MWTRN."Diagnosis Code 1", 
         MWTRN."Diagnosis Code 2", 
         MWTRN."Diagnosis Code 3", 
         MWTRN."Diagnosis Code 4", 
         MWTRN."Date From", MWTRN."Date To", 
         MWPAT."Last Name", MWPAT."First Name"

After generating the dataset how can I go back and pair down the results?

I've read a couple of the ad supported SQL tutorial sites to read the generated SQL and thought what I needed was DISTINCT but this only checks whether the whole record is distinct, not just the ID.

-- Layman using Advantage Database Server and reporting software which may be tied to Crystal Reports somehow.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

锦欢 2024-10-01 09:06:15

为了进行测试,您需要使用 Advantage Data Architect,可以从 Advantage DevZone 下载。 http://devzone.advantagedatabase.com 此外,您还需要完整的帮助文件,其中包括Cary Jensen 精彩的“Advantage 数据库服务器,开发人员指南”在同一位置提供,它将帮助您快速了解 Advantage 中的 SQL 以及一般的 SQL。
您有多种选择,具体取决于您想要实现的目标。
您可以创建一个 SQL 脚本并将语句放入临时表中,如下所示,

Select into #MyTemp --all the rest of the complex SQL command--

然后您可以对该文件执行您想要的操作来削减它。但是,如果您只想要具有特定诊断代码的患者列表,您可以执行类似的操作

Select pat.id, pat.name, pat.address from pat where pat.id in (Select id from tran where diag1 in ('123.3','123.4') UNION Select id from tran where diag2 in ('123.3','123.4') UNION
Select id from tran where diag3 in ('123.3','123.4') UNION Select id from tran where diag4 in ('123.3','123.4');

,如果您需要在 Crystal 中执行此操作,则可以使用 AddCommand 部分创建该联合集...只需确保您正在使用 Advantage Crystal 驱动程序,设置正确,并且可以从...您猜对了...Advantage Devzone

希望有所帮助。

For you testing purposes you will want to have Advantage Data Architect, downloadable from the Advantage DevZone. http://devzone.advantagedatabase.com In addition, you will want the full help file which includes a copy of Cary Jensen's marvelous "Advantage Database Server, a Developer's Guide", available the same place, which will help you with the getting up to speed on SQL in Advantage, and SQL in general.
You have a couple of options depending on exactly what it is you are trying to accomplish.
You could create an SQL script and take your statement into a temporary table as in

Select into #MyTemp --all the rest of the complex SQL command--

Then you can do what you want with that file to pare it down. If, however, you just want a list of patients that have a certain diagnosis code, you can do something like

Select pat.id, pat.name, pat.address from pat where pat.id in (Select id from tran where diag1 in ('123.3','123.4') UNION Select id from tran where diag2 in ('123.3','123.4') UNION
Select id from tran where diag3 in ('123.3','123.4') UNION Select id from tran where diag4 in ('123.3','123.4');

And if you need to do it in Crystal, you can create that union set using the AddCommand section...just make sure you are using the Advantage Crystal Driver, set up correctly, and obtainable from...you guessed it...Advantage Devzone

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文