读书人

示,该怎么解决

发布时间: 2012-01-01 23:10:55 作者: rapoo


在有一 容是
A
A
B
B
C
C
我在就想示里面有重的
A
B
C
怎么用SQL法?

[解决办法]
Select Distinct 字段 From 表
[解决办法]
select distinct 字段 from 表.
[解决办法]
Select 字段 From 表 Group By 字段
[解决办法]
--------------例子--------
create table A(name varchar(10),scot int)
insert A
select 'a ',1 union all
select 'b ',1 union all
select 'c ',1 union all
select 'd ',2 union all
select 'e ',2

1。
select min(name),scot from a group by scot ---第一种方法

2。
select
t.*
from
a t
where
not exists(select 1 from a where name <t.name and scot=t.scot) ---第二种方法

读书人网 >SQL Server

热点推荐