日期:2014-05-18  浏览次数:20553 次

sqlserve 2005 去掉重复数据的一个问题
是这样的,我写了个sql:
select min(A.id ),order_id from A group by A.order_id 这样我就去掉这个表的重复数据了,但是呢,这只是第一步,我查出来的这个结果的id 是另外一张表的条件

select ....... from a,b where ...... and a.id in(刚才上边写的那段)也就是:
select ....... from a,b where ...... and a.id in(
  select min(A.id ),order_id from A group by A.order_id )我以为能执行呢,但是报错:


消息 116,级别 16,状态 1,第 1 行
当没有用 EXISTS 引入子查询时,在选择列表中只能指定一个表达式。
这个怎么解决啊,sql高手请指教啊

------解决方案--------------------
SQL code
select ....... from a,b where ...... and a.id in(
  select min(A.id ) from A group by A.order_id )