使用城市和配置文件名称计算给定查询

时间:2017-06-19 06:37:26

标签: sql sql-server select

select b.ProfileName,c.City from tblJobs as a 
inner join tblProfile as b on b.ID = a.ProfileID
inner join tblCity as c on c.CityID = a.CityID

O / P

Profile Name        City

Gym Manager         Mumbai  
Personal Trainer    Mumbai  
Personal Trainer    Mumbai  
Personal Trainer    Bengaluru  

1 个答案:

答案 0 :(得分:1)

似乎你所缺少的只是一个group by条款和对count的调用:

SELECT     b.ProfileName, c.City, COUNT(*)
FROM       tblJobs AS a 
INNER JOIN tblProfile AS b ON b.ID = a.ProfileID
INNER JOIN tblCity AS c ON c.CityID = a.CityID
GROUP BY   b.ProfileName, c.City