Qns: Item Description and the treatment date of all treatments for any patients named Jessie Stange (ie GivenName is Jessie & FamilyName is Stange)
Qns:项目描述和任何名为Jessie Stange的患者的治疗日期(即GivenName是Jessie&FamilyName是Stange)
What I wrote:
我写的:
SELECT DISTINCT
Description,
Date as treatmentDate
WHERE doothey.Patient P,
doothey.Account A,
doothey.AccountLine AL,
doothey.Item.I AND
P.PatientID = A.PatientID AND
A.AccountNo = AL.AccountNo AND
AL.ItemNo = I.ItemNo AND
(p.FamilyName = 'Stange' AND p.GivenName = 'Jessie');
Error:
Error at Command Line:1 Column:30 Error report: SQL Error: ORA-00936: missing expression 00936. 00000 - "missing expression" *Cause: *Action:
命令行出错:1列:30错误报告:SQL错误:ORA-00936:缺少表达式00936. 00000 - “缺少表达式”*原因:*操作:
What is the missing expression?
丢失的表达是什么?
2 个解决方案
#1
4
Correct syntax below.
正确的语法如下。
SELECT DISTINCT Description, Date as treatmentDate
FROM
doothey.Patient P, doothey.Account A, doothey.AccountLine AL, doothey.Item I
WHERE P.PatientID = A.PatientID AND A.AccountNo = AL.AccountNo
AND AL.ItemNo = I.ItemNo
AND (p.FamilyName = 'Stange' AND p.GivenName = 'Jessie');
Although above query would work but the recommended way is by using ANSI SQL JOIN syntax is
虽然上面的查询可行,但推荐的方法是使用ANSI SQL JOIN语法
SELECT DISTINCT Description, Date as treatmentDate
FROM doothey.Patient P
INNER JOIN doothey.Account A
ON P.PatientID = A.PatientID
INNER JOIN doothey.AccountLine AL
ON A.AccountNo = AL.AccountNo
INNER JOIN doothey.Item I
ON AL.ItemNo = I.ItemNo
WHERE
p.FamilyName = 'Stange' AND p.GivenName = 'Jessie';
#2
0
As people have commented you missed the FROM
statement in your select.
正如人们所评论的那样,你在选择中错过了FROM语句。
I would also suggest not just declaring all your tables in the FROM
and specifying links in the WHERE
clause, but instead join
the tables together using LEFT JOIN
and/or INNER JOIN
s, etc.
我还建议不仅在FROM中声明所有表并在WHERE子句中指定链接,而是使用LEFT JOIN和/或INNER JOIN等将表连接在一起。
Below is the query I think should cover what I have tried to explain above.
以下是我认为应该涵盖我上面试图解释的问题。
SELECT DISTINCT
Description,
Date as treatmentDate
FROM
doothey.Patient P
INNER JOIN
doothey.Account A
ON
P.PatientID = A.PatientID
INNER JOIN
doothey.AccountLine AL
ON
A.AccountNo = AL.AccountNo
INNER JOIN
doothey.Item.I
ON
AL.ItemNo = I.ItemNo
WHERE
p.FamilyName = 'Stange'
AND
p.GivenName = 'Jessie'
#1
4
Correct syntax below.
正确的语法如下。
SELECT DISTINCT Description, Date as treatmentDate
FROM
doothey.Patient P, doothey.Account A, doothey.AccountLine AL, doothey.Item I
WHERE P.PatientID = A.PatientID AND A.AccountNo = AL.AccountNo
AND AL.ItemNo = I.ItemNo
AND (p.FamilyName = 'Stange' AND p.GivenName = 'Jessie');
Although above query would work but the recommended way is by using ANSI SQL JOIN syntax is
虽然上面的查询可行,但推荐的方法是使用ANSI SQL JOIN语法
SELECT DISTINCT Description, Date as treatmentDate
FROM doothey.Patient P
INNER JOIN doothey.Account A
ON P.PatientID = A.PatientID
INNER JOIN doothey.AccountLine AL
ON A.AccountNo = AL.AccountNo
INNER JOIN doothey.Item I
ON AL.ItemNo = I.ItemNo
WHERE
p.FamilyName = 'Stange' AND p.GivenName = 'Jessie';
#2
0
As people have commented you missed the FROM
statement in your select.
正如人们所评论的那样,你在选择中错过了FROM语句。
I would also suggest not just declaring all your tables in the FROM
and specifying links in the WHERE
clause, but instead join
the tables together using LEFT JOIN
and/or INNER JOIN
s, etc.
我还建议不仅在FROM中声明所有表并在WHERE子句中指定链接,而是使用LEFT JOIN和/或INNER JOIN等将表连接在一起。
Below is the query I think should cover what I have tried to explain above.
以下是我认为应该涵盖我上面试图解释的问题。
SELECT DISTINCT
Description,
Date as treatmentDate
FROM
doothey.Patient P
INNER JOIN
doothey.Account A
ON
P.PatientID = A.PatientID
INNER JOIN
doothey.AccountLine AL
ON
A.AccountNo = AL.AccountNo
INNER JOIN
doothey.Item.I
ON
AL.ItemNo = I.ItemNo
WHERE
p.FamilyName = 'Stange'
AND
p.GivenName = 'Jessie'