日期:2014-05-19  浏览次数:20650 次

SELECT 连接的 问题
有   两条select

SELECT   A.CODE,B.[NAME],SUM(A.POINTS)  
FROM       ACTIVITIES   AS   A
LEFT   JOIN   MEMBER   AS   B   ON     A.CODE=B.CODE
WHERE     A.TYPE=0
GROUP   BY   A.CODE,B.[NAME]    

SELECT   A.CODE,B.[NAME],SUM(A.POINTS)  
FROM       ACTIVITIES   AS   A
LEFT   JOIN   MEMBER   AS   B   ON     A.CODE=B.CODE
WHERE     A.TYPE=120  
GROUP   BY   A.CODE,B.[NAME]

怎么样连接啊



------解决方案--------------------
這個意思??

SELECT A.CODE,B.[NAME],SUM(A.POINTS)
FROM ACTIVITIES AS A
LEFT JOIN MEMBER AS B ON A.CODE=B.CODE
WHERE A.TYPE=0
GROUP BY A.CODE,B.[NAME]
Union All
SELECT A.CODE,B.[NAME],SUM(A.POINTS)
FROM ACTIVITIES AS A
LEFT JOIN MEMBER AS B ON A.CODE=B.CODE
WHERE A.TYPE=120
GROUP BY A.CODE,B.[NAME]