如何在加入后使用组

时间:2018-04-06 08:56:49

标签: sql sql-server join group-by

Sql Query:

select Song.name as Song, Band.name as Band        
from Song join BandOnSong on Song.Id = BandOnSong.songId
join Band on BandOnSong.bandId = Band.Id;

结果:

Song              Band
Live Forever      Oasis
Penny Lane        The Beatles
Penny Lane        Test
Where is My Mind  Pixies

预期结果:

Song              Band
Live Forever      Oasis
Penny Lane        The Beatles, Test
Where is My Mind  Pixies

如何获得预期结果?我尝试在Song.name上使用一个组,但是我做错了。

0 个答案:

没有答案