问题描述
编写SQL查询
1.能够识别患者保险公司名称的数据
2.能够描述患者地理位置的数据
3.显示手术期间药物总费用的汇总栏
HOSPITALEMRDATA
dbo 。保险提供商
ProviderName
城市
状态
邮编
dbo.Patiens
PatientID
PatientName
出生日期
MRN
dbo.PatientVisits
PatientVisitID
PatientID
AdmissionDate
DischargeDate
InsuranceProviderID
PatientCity
PatientState
PatientZip
SURGERYDATA.DBO
dbo.Drug_Administration
DrugAdministraionID
CaseID
DrugID
TimeGiven
QuantityGiven
dbo.Cases
CaseID
MRN
SurgeryData
SurgeryStart
SurgeryFinish
ServiceLineID
dbo.Drugs
DrugID
名称
成本
dbo.ServiceLine
ServiceLineID
ServiceLineName
我是什么尝试过:
从HospitalEmrData.dbo.PatientVisit,InsuranceProviders,选择PatientName,PatientCity,PatientState,PatientZip,ProviderName
,患者
从这里被困......
Write an SQL Query
1. Data capable of identifying the patient’s insurance company name
2. Data capable of describing the patient’s geographic location
3. An aggregation column showing the total cost of drugs administered during surgery
HOSPITALEMRDATA
dbo.InsuranceProvider
ProviderName
City
State
Zip
dbo.Patiens
PatientID
PatientName
Birthdate
MRN
dbo.PatientVisits
PatientVisitID
PatientID
AdmissionDate
DischargeDate
InsuranceProviderID
PatientCity
PatientState
PatientZip
SURGERYDATA.DBO
dbo.Drug_Administration
DrugAdministraionID
CaseID
DrugID
TimeGiven
QuantityGiven
dbo.Cases
CaseID
MRN
SurgeryData
SurgeryStart
SurgeryFinish
ServiceLineID
dbo.Drugs
DrugID
Name
Cost
dbo.ServiceLine
ServiceLineID
ServiceLineName
What I have tried:
Select PatientName, PatientCity, PatientState, PatientZip, ProviderName
from HospitalEmrData.dbo.PatientVisit, InsuranceProviders, Patients
Stuck from here...
推荐答案
Select PatientName, PatientCity, PatientState, PatientZip, ProviderName
from HospitalEmrData.dbo.PatientVisit, InsuranceProviders, Patients
对不起,但似乎你是非常初学者。我建议从这里开始: [],因为你是使用 [],返回 []。
根据具体情况,您需要使用 INNER,LEFT或RIGHT JOIN
,但不能 CROSS JOIN
!
BTW:这是你的功课。你必须自己解决。
Sorry, but it seems you're very beginner. I'd suggest to start here: Visual Representation of SQL Joins[^], because you're using CROSS JOIN[^], which returns the Cartesian product[^] of the tables involved in the join.
Depending on situation, you need to use INNER, LEFT or RIGHT JOIN
, but not CROSS JOIN
!
BTW: It's your homework. You have to resolve it yourself.
这篇关于如何为以下内容编写SQL查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!