首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

數據庫數據顯示問題,该怎么解决

2012-01-01 
數據庫數據顯示問題現在有一個數據庫內容是AABBCC我現在就想顯示里面沒有重復的數據ABC怎么用SQL語法實現?

數據庫數據顯示問題
現在有一個   數據庫內容是
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) ---第二种方法

热点排行