SELECT COURSENAME
FROM COURSE C1
WHERE (1) IN
(SELECT COUNT(DISTINCT(C2.COURSEFEES))
FROM COURSE C2
WHERE C2.COURSEFEES > C1.COURSEFEES);


“ WHERE(1)IN”是什么意思?

最佳答案

这是一种笨拙的书写方式:

WHERE (SELECT COUNT(DISTINCT C2.COURSEFEES)
       FROM COURSE C2
       WHERE C2.COURSEFEES > C1.COURSEFEES
      ) = 1


这就是说,课程费用比记录中的费用要大-或者,课程费用是第二高的。

将其看似可能更简单:

WHERE C1.COURSEFEES = (SELECT C2.COURSEFEES
                       FROM COURSE C2
                       GROUP BY C2.COURSEFEES
                       ORDER BY C2.COURSEFEES DESC
                       LIMIT 1 OFFSET 1
                      )

关于mysql - (n)在SQL查询中的含义?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51724529/

10-10 03:31