1

我的查询是:

select a from b where c in (
    select d from e where f in (
        select f from e where d=100)
    and e!=100 group by e order by count(e) desc
   )
)

此查询将输出我想要的结果,但我想通过此子查询对其进行排序

select d from e where f in (
    select f from e where d=100)
and e!=100 group by e order by count(f) desc

基本上我想按 count(f) 排序

我怎样才能实现主查询从子查询中获取 id 但它不会根据子查询对它们进行排序

4

1 回答 1

1

从您添加的 SQL 中,我得出如下内容:

    SELECT e1.d
  FROM e e1,
       (SELECT *
          FROM e
         WHERE d = 100) e2
 WHERE e1.f = e2.f AND e1.e != 100
GROUP BY e1.e
ORDER BY COUNT (e2.f)
于 2012-08-16T23:17:50.367 回答