sql問題---分全給了

zhang_winnie 2010-09-08 11:47:22
現有一張表Test,如下:
ID tille1 tille2 tille3
1 數學 張三 15
2 數學 李四 21
3 語文 張三 16
4 數學 王五 17
5 語文 李四 31
6 語文 金六 30
現在我想得到的查詢結果是:
tille1 tille2 tille3
數學 張三 15
數學 李四 21
數學 王五 17
語文 金六 30
先謝謝各位
...全文
245 31 打赏 收藏 转发到动态 举报
写回复
用AI写文章
31 条回复
切换为时间正序
请发表友善的回复…
发表回复
gaven2060 2010-09-09
  • 打赏
  • 举报
回复
这样过滤重复的
select tille1,tille2,tille3 from Test where not exists(select 1 from Test where tille2=a.tille2)
这个是排序的
order by title desc
sunguoshun 2010-09-09
  • 打赏
  • 举报
回复
需求不明确阿
bing0804 2010-09-09
  • 打赏
  • 举报
回复
简单得很:

select ID, tille1, tille2, tille3 from Test
where id in(select distinct id from test)
  • 打赏
  • 举报
回复
直接分组tille1得了 后面不管
changjiangzhibin 2010-09-08
  • 打赏
  • 举报
回复
Title2 重复怎么取
Diza1986 2010-09-08
  • 打赏
  • 举报
回复
先过滤还是先排序?

如果是想把过滤tille2以后的结果再以tille1排序的话
select tille1,tille2,tille3 from (
select tille1,tille2,tille3,row_number() over (partition by tille2 order by ID) as num from test )
where num = 1
order by tille1
Diza1986 2010-09-08
  • 打赏
  • 举报
回复
select tille1,tille2,tille3 from (
select tille1,tille2,tille3,row_number() over (partition by tille2 order by tille1) as num from test )
where num = 1
order by tille1

临时写的,试一下
zhang_winnie 2010-09-08
  • 打赏
  • 举报
回复
目的:過濾重複的tille2,排序tille1,謝謝
shbz1986 2010-09-08
  • 打赏
  • 举报
回复
目的是什么?不懂!!!
五更琉璃 2010-09-08
  • 打赏
  • 举报
回复
select tille1,tille2,
(select t.tille3 from test as t where t.tille1=tille1 and t.tille2=tille2 )as tille3
from Test group by tille1,tille2
不知道是不是LZ要的
有泪为清流 2010-09-08
  • 打赏
  • 举报
回复
select tille1,tille2,tille3 from Test
不可以吗?
healer_kx 2010-09-08
  • 打赏
  • 举报
回复
原则是什么啊?
wuguoxian001 2010-09-08
  • 打赏
  • 举报
回复
select title1,distinct(title2),title3 from title order by title1
gaara777 2010-09-08
  • 打赏
  • 举报
回复
不明白要干什么
zly182320 2010-09-08
  • 打赏
  • 举报
回复
不明白你是什么意思~~~
lxgloveme 2010-09-08
  • 打赏
  • 举报
回复
名字重复时,学科怎么取
c2008200613 2010-09-08
  • 打赏
  • 举报
回复
学习型学习
乐居猫 2010-09-08
  • 打赏
  • 举报
回复
真不知道 这题怎么来的
ajax_webservice 2010-09-08
  • 打赏
  • 举报
回复
SELECT a.tille1,a.tille2,a.tille3 FROM test a where ID=(SELECT MIN(ID) FROM test WHERE tille2=a.tille2) ORDER BY a.tille1


粥是稀饭 2010-09-08
  • 打赏
  • 举报
回复
试试用用Min函数和Max 函数,LZ是不是,要选择出每人成绩低的些信息?
加载更多回复(10)

111,129

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧