日期:2014-05-18  浏览次数:20501 次

这句SQL语句怎么改才能显示名称


SQL code
SELECT     a.SceneId, COUNT(distinct a.UsersName) AS Expr1
FROM         ApplyInfo AS a INNER JOIN
                      UsersInfo AS u ON a.UsersName = u.UsersName
WHERE     (u.UsersSex = '男')
GROUP BY a.SceneId



我想要把 SELECT【a.SceneId】 改成显示【SceneInfo的SceneName】怎么改,其他都不变

------解决方案--------------------
SQL code

SELECT     S.SceneName, COUNT(distinct a.UsersName) AS Expr1
FROM         ApplyInfo AS a INNER JOIN
                      UsersInfo AS u ON a.UsersName = u.UsersName
                            Inner join 
                     SceneInfo AS S on a.SceneId=S.SceneId
WHERE     (u.UsersSex = '男')
GROUP BY S.SceneName

------解决方案--------------------
SQL code
SELECT     SC.SceneName, COUNT(distinct a.UsersName) AS Expr1
FROM         ApplyInfo AS a INNER JOIN
                      UsersInfo AS u ON a.UsersName = u.UsersName
inner join sceneinfo SC on SC.sceneid =a.sceneid
WHERE     (u.UsersSex = '男')
GROUP BY SC.SceneName