select count(user_id) from (select distinct user_id from 表1)//这句查的是从表1中查出不同的user_idselect count(*) from (select * from 表2 where product_name is not null order by product_bussiness_count desc) where user_id={0} and sort_id=11 and (rownum<2)这句是根据条件查询我现在想做的是:加了一个AspNetPage控件,之前没加分页时,实现的是先查出不同的user_id,然后再根据user_id和sort_id查出产品(每个用户只提取1个产品),但现在加上分页,就不知道怎么做了,能不能把上面的两句话合成一句?

解决方案 »

  1.   

    不用上面那个了,现在只要做到查出不同的user_id并且product_name不能为空,这个也是查个数,但是我还没想出怎么把这个写成一句,如果加上product_name的话,那查出的user_id就会有重复的,求解!!!
      

  2.   

    select count(*) from (select * from 表2 where product_name is not null order by product_bussiness_count desc) where user_id in (select distinct user_id from 表1) and sort_id=11 and (rownum<2)  这样可以把
      

  3.   

    SELECT TOP PAGESIZE * FROM TABLE1 WHERE ID>(SELECT MAX(ID) FROM (SELECT TOP PAGESIZE*PAGENO ID FROM TABLE1 WHERE 1=1 AND 条件 ORDER BY ID)AS T)