两个问题:
1)我希望把数据库中所有点击次数相同的记录只取出其中的一条,如何做?(我用了select distinct hits,name,type from mydbtable order by hits,结果还是把所有点击次数相同的记录全部取出来了。这是为什么?应该如何做?)2)我的页面上有一个下载地址的超链接,我希望在点击链接下载文件的同时,更新数据库的hits字段,该如何做?(我用了linkbutton,虽然可以更新数据库,但却不能下载文件?这是为什么,应该如何做?)请高手给予帮助!!!谢谢了。

解决方案 »

  1.   

    1)
    select hits
    from mydbtable 
    GROUP BY hits
    order by hits
      

  2.   

    2)
    count.aspx,用来统计次数
    下载地址:count.aspx?target=aaaaa.rar
    取参数更新hits!
      

  3.   

    不行啊! 我还希望能找出name,type字段等。
      

  4.   

    select hits,name,type
    from mydbtable 
    GROUP BY hits,name,type
    order by hits
      

  5.   

    select top 1 hits,name,type from mydbtable group by hits order by hits
      

  6.   

    还是不行啊。找出来的还是那么多条hits值相同的记录。5555555555
      

  7.   

    select hits,name,type from mydbtable group by hits order by hits
      

  8.   

    我希望把数据库中所有点击次数相同的记录只取出其中的一条,这个地方有个策略问题select * from mydbtable a where not exists(select 1 from mydbtable where a.hit = hit and a.name>name)
      
      

  9.   

    select distinct hits,
    (select top 1 name from mydbtable where hits=mydbtable.hits) name,
    (select top 1 type from mydbtable where hits=mydbtable.hits) type 
    from mydbtable