SELECT a.[UserID],b.[Name],sum (c.[Money]+c.[Bank])as TotalMoney
FROM Table1 a(nolock)
LEFT JOIN Table2 b(nolock) on a.[UserID] = b.[UserID]
LEFT JOIN Table3 c(nolock) ON b.[UserID]=c.[UserID]
WHERE a.[UserID] = b.[UserID] and a.[UserID] = c.[UserID] and a.[Time] >= ‘2005-01-01‘ AND a.[Time] <= ‘2006-12-31‘
GROUP BY a.[UserID],b.[Name]
ORDER BY a.[Time] DESC
优化一下
================================================================================
Left Join 语法:
select * from
table1 left join table2 on 条件1
left join table3 on 条件2
left join table4 on 条件3
where 条件4
GROUP BY 说明: