oracle:
sql如下
select rownum rn,b.* from
(
select a.movie_count,mi.* from
(
select count(mpi.movie_id) movie_count,mpi.movie_id from movie_playhis_info mpi,ixterminal tml
where mpi.tml_id = tml.tml_id and tml.cinema_id = 5 and tml.group_id = 6 and mpi.start_time > '2010-01-01' and 
mpi.start_time < '2020-01-01' group by mpi.movie_id
) a,movie_info mi
where a.movie_id = mi.movie_id ORDER BY A.MOVIE_COUNT DESC


) B
换成sql server如何写

解决方案 »

  1.   

    select ROW_NUMBER() over (order by getdate()) rn,b.* from
    (
        select a.movie_count,mi.* from
        (
        select count(mpi.movie_id) movie_count,mpi.movie_id from movie_playhis_info mpi,ixterminal tml
        where mpi.tml_id = tml.tml_id and tml.cinema_id = 5 and tml.group_id = 6 and mpi.start_time > '2010-01-01' and 
        mpi.start_time < '2020-01-01' group by mpi.movie_id
        ) a,movie_info mi
        where a.movie_id = mi.movie_id ORDER BY A.MOVIE_COUNT DESC
        
        
    ) B
      

  2.   

    row_number() over (order by getdate()) as  rn
      

  3.   

    不通用的 
    楼主 这个你在oracle执行正确吗 mpi.start_time > '2010-01-01' and 
        mpi.start_time < '2020-01-01'