0

我有一个query包含 3 个字段的表(int)ID(string)query并且(int)freq。我需要找出与第二高频率的查询匹配关键字的所有查询。这是我尝试过的,

select * from query 
where query like concat('%',(Select query from query 
where freq = (Select min(freq) from query
where freq in (Select freq from query order by freq desc limit 2))),'%');

我认为“选择查询来自”行隔离了查询列,之后不选择任何东西。最后 2 个 select 语句给出频率第二高的查询。请让我知道我做错了什么。

4

1 回答 1

0
SELECT ID, QUERY, FREQ
FROM
(
SELECT ID, QUERY, FREQ, ROW_NUMEBER() OVER(ORDER BY FREQ DESC) RN
FROM QUERY
) A
WHERE RN = 2
于 2013-04-07T07:15:54.980 回答