我认为错误描述有点误导,因为我看不出查询结束的方式有什么问题。我正在尝试加入三个表,但这是行不通的。有人可以指出我做错了什么吗?顺便说一句,这是在 Oracle 上。
SELECT s.PITIMEDATE, ROUND(SYSDATE-s.PITIMEDATE) DIFFDAYS, s.SRC, s.VSA6, a.VSA9, c.COMMENTS, c.Actions, c.MYID
FROM alarm_standing_MAU AS s
INNER JOIN alarm_MAU AS a
ON a.SRC = s.SRC
AND a.VSA9 =
(SELECT VSA9
FROM a
WHERE a.SRC = s.SRC
AND ROWNUM=1)
INNER JOIN Alarm_Standing_Comments AS c
ON c.SRC = s.SRC
AND s.SRC<>'LastCheck'
GROUP BY s.SRC, s.PITIMEDATE, s.VSA6, a.VSA9, c.Comments, c.Actions, c.MYID
ORDER BY s.PITIMEDATE ASC
有关更多信息,我试图向查询添加第二个连接,但它变得有点笨拙,因此正在尝试使用别名。这是最初的查询 - 我想知道如何通过别名提高可读性。
SELECT alarm_standing_MAU.PITIMEDATE, ROUND(SYSDATE-alarm_standing_MAU.PITIMEDATE) DIFFDAYS, alarm_standing_MAU.SRC, alarm_standing_MAU.VSA6, alarm_MAU.VSA9
FROM alarm_standing_MAU
INNER JOIN alarm_MAU
ON alarm_MAU.SRC = alarm_standing_MAU.SRC
AND alarm_MAU.VSA9 =
(SELECT VSA9
FROM alarm_MAU
WHERE alarm_MAU.SRC = alarm_standing_MAU.SRC
AND ROWNUM=1)
AND alarm_standing_MAU.SRC<>'LastCheck'
GROUP BY alarm_standing_MAU.SRC, alarm_standing_MAU.PITIMEDATE, alarm_standing_MAU.VSA6, alarm_MAU.VSA9
ORDER BY alarm_standing_MAU.PITIMEDATE ASC