select * from [CustomerRegisters] WHERE studentd<'500'这个查询语句可以输出studentd 小于 500 所有的行,请教下 如果需要让它每个值只为1行 也就是499行 ,这个怎么样可以实现,谢谢!

解决方案 »

  1.   

    这要用另一个或多个行来比较才行,也就是说,重复的行,你选哪一个.
    如果两行是完全重复的,则:
    select distinct * from [CustomerRegisters] WHERE studentd<'500'
    如果只是部分重复,而有不重复的,比如 id 是唯一的,则:
    select * from [CustomerRegisters] a WHERE studentd<'500' and not exists(
    select 1 from CustomerRegisters where studentd=a.studentd and id>a.id
      

  2.   

    没太懂,你可以这样写下 不知道是不是要的结果
    select * from [CustomerRegisters] WHERE studentd<'500'
    group by   studentd
      

  3.   

    差个右括号:
    select * from [CustomerRegisters] a WHERE studentd<'500' and not exists(
    select 1 from CustomerRegisters where studentd=a.studentd and id>a.id)
      

  4.   


    select distinct * from [CustomerRegisters] WHERE studentd<'500'
      

  5.   

    是想去重复的吗 
    distinct 关键字就好了 
    select * from [CustomerRegisters] WHERE studentd<'500'把表结构和结果贴出来
      

  6.   


    谢谢您的答案!不过这样只能查出不重复的列ID的行!在STUdentd列中有着大量一样值得行,有些可能有几千行,我需要每一个STUDENTD 一个ID值只输出一行 
    这个有办法吗?