Select *

From MovieList m1

where   ID in (select top 50 ID from MovieList m2 where m2.agency = m1.agency  order by m2.id desc)

order by agency

记录下这句sql,第一次看到如此的用法,可能会在数据量大的情况下性能不好,不过能写出这样的语句,思维能力让我佩服。

这个sql实现的功能就是:一学校有n个班,每个班取50个同学出来。

相关文章:

  • 2022-12-23
  • 2021-08-21
  • 2022-01-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
猜你喜欢
  • 2021-08-19
  • 2021-06-24
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
相关资源
相似解决方案