当前位置: 代码迷 >> Sql Server >> 再次高人,这条语句又该怎么简化
  详细解决方案

再次高人,这条语句又该怎么简化

热度:95   发布时间:2016-04-27 15:10:11.0
再次请教各位高人,这条语句又该如何简化
SELECT   name,
                    (SELECT   COUNT(id)
                  FROM   class
                  WHERE   f_grade_id   =   1   AND   type   =   dbo.basicmess.id)   AS   todal
FROM   dbo.basicmess
WHERE   (type   =   1)

------解决方案--------------------
try

SELECT A.name,
COUNT(B.id) AS todal
FROM dbo.basicmess A
Left Join class B
On B.f_grade_id = 1 AND B.type = A.id
WHERE (A.type = 1)
  相关解决方案