如下:子查询中不允许sql order by现在我要找回 userid 以及 username 从用户表。我就是这么做的:
userid
username
select * from user where user.username in (select top 30 username, count(*) as n_plays from plays group by username order by n_plays desc)
为什么我会出错?
tp5buhyn1#
我不知道你为什么会犯那个错误。你有一个 in 应返回一列但返回两列的子查询。替代用途 join :
in
join
select u.* from user u join (select top 30 username, count(*) as n_plays from plays p group by p.username order by count(*) desc ) pu on pu.username = u.username;
1条答案
按热度按时间tp5buhyn1#
我不知道你为什么会犯那个错误。你有一个
in
应返回一列但返回两列的子查询。替代用途join
: