首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

这句SQL语句如何改才能显示名称

2012-05-01 
这句SQL语句怎么改才能显示名称SQL codeSELECTa.SceneId, COUNT(distinct a.UsersName) AS Expr1FROMApply

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


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



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

[解决办法]
SQL code
SELECT     S.SceneName, COUNT(distinct a.UsersName) AS Expr1FROM         ApplyInfo AS a INNER JOIN                      UsersInfo AS u ON a.UsersName = u.UsersName                            Inner join                      SceneInfo AS S on a.SceneId=S.SceneIdWHERE     (u.UsersSex = '男')GROUP BY S.SceneName
[解决办法]
SQL code
SELECT     SC.SceneName, COUNT(distinct a.UsersName) AS Expr1FROM         ApplyInfo AS a INNER JOIN                      UsersInfo AS u ON a.UsersName = u.UsersNameinner join sceneinfo SC on SC.sceneid =a.sceneidWHERE     (u.UsersSex = '男')GROUP BY SC.SceneName 

热点排行