在同一行中显示2列值 - SQL [英] Display 2 column values in the same row - SQL
本文介绍了在同一行中显示2列值 - SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好。我有这样一张桌子:
Hi everybody. I have a table like this:
ID_game | ID_team | points | home
-------------------------------------
1 | 1 | 87 | true
-------------------------------------
1 | 2 | 79 | false
如何在同一行显示参加比赛的球队积分,如下所示:
How can I display points of teams who played the match in the same row, like this:
87 | 79
我的尝试:
我很容易在这样的不同行显示点数:
What I have tried:
It's easy for me to display points in different rows like this:
87
---
79
提前致谢。
Thanks in advance.
推荐答案
尝试:
Try:
SELECT a.ID_game, a.ID_team AS Home, a.Points AS [Home Points], b.ID_team AS Away, b.Points AS [Away Points] FROM MyTable a
JOIN MyTable b ON a.ID_game = b .ID_game AND a.home = 1 AND b.Home = 0
这篇关于在同一行中显示2列值 - SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文