SQLServer多表相同字段的其他字段数据汇总查询



SQLServer多表相同字段的其他字段数据汇总查询SQLServer多表相同字段的其他字段数据汇总查询

SELECT m.Application_department,COUNT(m.Application_department) AS Daily_matters,
                             (select COUNT(Department)
                              from S_workExaminationForm
                              where Department=m.Application_department
                              )AS Major_matters
                              FROM S_MilepostItem as m
                              GROUP BY m.Application_department 
                              HAVING      (COUNT(m.Application_department) > 0)

效果图:

SQLServer多表相同字段的其他字段数据汇总查询