4

Qns : 项目描述和任何名为 Jessie Stange 的患者的所有治疗的治疗日期(即 GivenName 是 Jessie,FamilyName 是 Stange)

我写的:

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 at Command Line:1 Column:30
Error report:
SQL Error: ORA-00936: missing expression
00936. 00000 -  "missing expression"
*Cause:    
*Action:

缺少的表达是什么?

4

5 回答 5

11

Your statement is calling SELECT and WHERE but does not specify which TABLE or record set you would like to SELECT FROM.

SELECT DISTINCT Description, Date as treatmentDate
FROM (TABLE_NAME or SUBQUERY)<br> --This is missing from your query.
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');
于 2013-11-15T13:23:30.007 回答
2

你犯了两个错误。我认为您放错了 FROM 和 WHERE 关键字。

SELECT DISTINCT Description, Date as treatmentDate
     FROM doothey.Patient P, doothey.Account A, doothey.AccountLine AL,  doothey.Item.I --Here you use "." operator to "I" alias 
  WHERE  -- WHERE should be located here. 
   P.PatientID = A.PatientID
    AND A.AccountNo = AL.AccountNo
    AND AL.ItemNo = I.ItemNo
    AND (p.FamilyName = 'Stange' AND p.GivenName = 'Jessie');
于 2016-12-19T07:43:27.137 回答
0

在上面的查询中,当我们尝试合并两个或多个表时,有必要使用连接并指定描述和日期的别名(这意味着您从中获取描述和日期值的表)

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';
于 2018-03-22T07:17:40.063 回答
0

您没有对表使用 FROM 表达式

SELECT DISTINCT Description, Date as treatmentDate
**FROM <A TABLE>**
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');
于 2021-01-20T07:34:39.413 回答
-2
  1  

     选择 ename 作为名称,
      2 萨尔作为工资,
      3部门,部门,
      4 来自(TABLE_NAME 或 SUBQUERY)
      5 emp,emp2,部门
      6 哪里
      7 emp.deptno = 部门.deptno 和
      8 emp2.​​deptno = emp.deptno
      9* 按部门名称排序

 来自(TABLE_NAME 或 SUBQUERY)
 *
第 4 行的错误:
ORA-00936: 缺少表达式`选择 ename 作为名称,
 萨尔作为工资,
 部门,部门,
  来自(TABLE_NAME 或 SUBQUERY)
  emp, emp2, 部门
   在哪里
  emp.deptno = dept.deptno 和
  emp2.​​deptno = emp.deptno
  按 dept.dname 排序
于 2014-01-28T05:47:28.033 回答