日期:2014-05-16 浏览次数:20657 次
SELECT [UserID],[Name],[RegisterDate],('下面3句的和') FROM [Acinfo]
select sum([Score]) as sum1 from [UserInfo] where [UserID] = 2
select sum([Price]*[Count]) as sum2 FROM [Property] where [UserID] = 2
select sum(PPrice*PCount) as sum3 FROM [Present] where [UserID] = 2
SELECT [UserID],[Name],[RegisterDate]
,((select sum([Score]) as sum1 from [UserInfo] where [UserID]=t.[UserID])
+(select sum([Price]*[Count]) as sum2 FROM [Property] where [UserID]=t.[UserID])
+(select sum(PPrice*PCount) as sum3 FROM [Present] where [UserID] =t.[UserID]))
AS [3句的和]
FROM [Acinfo] t (NOLOCK)
WHERE t.[UserID]=2
SELECT [UserID],[Name],[RegisterDate],sum([Score]) as sum1
, sum([Price]*[Count]) as sum2
,sum(PPrice*PCount) as sum3
FROM [Acinfo] a
JOIN [UserInfo] u ON a.UserID = u.UserID
JOIN Property p ON a.UserID = p.UserID
JOIN [Present] t ON a.UserID = t.UserID
GROUP BY [UserID],[Name],[RegisterDate]