2016-04-05 49 views
0

我有結果集,這樣要3行轉換成3列與內部SQL Server中加入

enter image description here

和查詢此結果集是

SELECT 
    dt.GangName, u.UserFullName,dt.Designation, v.RegNo, 
    dt.SignInTime, dt.SignOutTime, z.ZoneName 
FROM 
    DutyRoosterTeam dt 
INNER JOIN 
    DutyRooster dr ON dr.DutyRoosterID = dt.DutyRoosterID 
INNER JOIN 
    Users u ON u.UserId = dt.UserID 
INNER JOIN 
    Vehicle v ON v.VehicleId = dt.MTLID 
INNER JOIN 
    Zone z ON z.ZoneId = dt.ZoneID 

但我想這樣的結果集

enter image description here

回答