使用 SQL 将单元格值显示为列名
我在数据库中有如下表:
Name Grade Subject
Ami HD Java
Ami D C++
Bec D Java
Bec P C++
是否可以仅使用 SQL 以下面给出的格式显示它:
Name Java C++
Ami HD D
Bec D P
我已经努力尝试,但找不到解决方案。
谢谢。
I have got table as given below in database:
Name Grade Subject
Ami HD Java
Ami D C++
Bec D Java
Bec P C++
Is it possible to display it in format given below only using SQL:
Name Java C++
Ami HD D
Bec D P
I have tried hard, but couldn't find a solution.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
您的表的问题是没有可以聚合列的数值,因此您可以使用 Min 或 max 作为聚合。
您可以在数据资源管理器此处查看正在运行的查询< /a>
Try this:
The problem with your table is that there is no numeric value you can aggregate your columns with, so you can use Min or max as an aggregate.
You can see the query in action in Data Explorer here