怎样得到数据库里面重复的记录,并把这些记录显示在DATAGRID同一行上?目的:检查出重复的入库单号
描述:由于单据印刷的问题,后面有一批入库单号跟前面的入库单号重复。所不同的是前面的0数量不一样。
      譬如:前面的单号叫:000678,后面的这张叫:00678。
      现在要将该些单据找出来。   入库单号(前)        入库时间         入库单号(后)       入库时间
     000678             2000-10-10          00678              2003-1-1

解决方案 »

  1.   

    没看懂意思,是不是想要这样的?:
    select * from table 入库单号(前)=入库单号(后)
      

  2.   

    单号都是数字型的字符吗?
    如果是的话,用下面的代码:select Convert(bigint,Code),count(Code) from table group by Convert(bigint,Code)
      

  3.   

    这段代码完整:select * from table
    where Convert(bigint,Code) in
    (
    select Convert(bigint,Code)
    from table
    group by Convert(bigint,Code)
    Having Count(Code)>1
    )
      

  4.   

    如果不仅仅是数字的话就要用函数将字符前端的'0'去掉查找重复的记录我一般喜欢用Group来进行
      

  5.   

    select a.*
    from YourTable a inner join (select item_no, min(price) as price from YourTable group by item_no) b on a.item_no = b.item_no and a.price = b.price.