向各位请教一个疑难问题

wxch 2012-11-05 11:12:00
表:姓名(xinming),语文分数(yuwen),数学分数(shuxue)
张三 90 80
张三 80 70
李四 70 80

请问如何通过SQL语句实现如下的显示结果
张三 90 80
80 70
李四 70 80
...全文
57 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
以学习为目的 2012-11-05
  • 打赏
  • 举报
回复
;with cte
as
(select *,rn=row_number() over(partition by xinming order by newid()) from tb)

select xinming=case when rn=1 then  xinming else '' end,
       yuwen,
       shuxue
from cte
快溜 2012-11-05
  • 打赏
  • 举报
回复
select xinming=case when no=1 then xinming else '' end,yuwen,shuxue from (select *,no=row_number() over(partition by xinming order by getdate() from tb))t

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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