问题描述
大家好
我有一个联接查询,显示Collegeid,学院名称,assignid
我想获得大学生人数.如何在下面的查询中编写计数查询.
请帮助
SELECT CollegeMaster.CollegeId,CollegeMaster.CollegeName,AssignMaster.TitleId AS Expr3,AssignMaster.AssignId,DomainMaster.DomainName,StudentMaster.CollegeId AS Expr1,TitleMaster.*
FROM AssignMaster INNER JOIN StudentMaster ON AssignMaster.ContactNo =
StudentMaster.ContactNo INNER JOIN
CollegeMaster ON StudentMaster.CollegeId = CollegeMaster.CollegeId INNER JOIN
TitleMaster开启AssignMaster.TitleId = TitleMaster.TitleId内联接
DomainMaster ON TitleMaster.DomainId = DomainMaster.DomainId和TitleMaster.DomainId = DomainMaster.DomainId,其中CollegeMaster.CollegeId ="8"和TitleMaster.TitleId ="1
Hi all
i have one join query that displays collegeid,collegename, assignid
i want to get the count of collegeid. how to write count query in below query.
please help
SELECT CollegeMaster.CollegeId, CollegeMaster.CollegeName, AssignMaster.TitleId AS Expr3, AssignMaster.AssignId, DomainMaster.DomainName, StudentMaster.CollegeId AS Expr1, TitleMaster.*
FROM AssignMaster INNER JOIN StudentMaster ON AssignMaster.ContactNo =
StudentMaster.ContactNo INNER JOIN
CollegeMaster ON StudentMaster.CollegeId = CollegeMaster.CollegeId INNER JOIN
TitleMaster ON AssignMaster.TitleId = TitleMaster.TitleId INNER JOIN
DomainMaster ON TitleMaster.DomainId = DomainMaster.DomainId AND TitleMaster.DomainId = DomainMaster.DomainId where CollegeMaster.CollegeId=''8'' and TitleMaster.TitleId=''1
推荐答案
SELECT COUNT(CollegeMaster.CollegeId),CollegeMaster.CollegeId, CollegeMaster.CollegeName, AssignMaster.TitleId AS Expr3, AssignMaster.AssignId, DomainMaster.DomainName, StudentMaster.CollegeId AS Expr1,
FROM AssignMaster
INNER JOIN StudentMaster
ON AssignMaster.ContactNo = StudentMaster.ContactNo
INNER JOIN CollegeMaster
ON StudentMaster.CollegeId = CollegeMaster.CollegeId
INNER JOIN TitleMaster
ON AssignMaster.TitleId = TitleMaster.TitleId
INNER JOIN DomainMaster
ON TitleMaster.DomainId = DomainMaster.DomainId
AND TitleMaster.DomainId = DomainMaster.DomainId
where CollegeMaster.CollegeId='8'
and TitleMaster.TitleId='1'
group by CollegeMaster.CollegeName, AssignMaster.TitleId,AssignMaster.AssignId, DomainMaster.DomainName, StudentMaster.CollegeId
这篇关于如何为此连接查询编写计数查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!