OK,搞定select M_ID, 
       M_Value1=isnull((select sum(s1_Value) from S1 Where S1_M_ID=M_ID),0),
       M_Value2=isnull((select sum(s2_Value) from S2 Where S2_M_ID=M_ID),0)
  From M

解决方案 »

  1.   

    最好:
    select M_ID, 
           M_Value1=isnull((select sum(s1_Value) from S1 Where S1_M_ID=M.M_ID),0),
           M_Value2=isnull((select sum(s2_Value) from S2 Where S2_M_ID=M.M_ID),0)
      From M
      

  2.   

    select M_ID, 
           Sum(IsNull(S1_Value,0)) as M_Value1, 
           Sum(IsNull(S2_Value,0)) as M_Value2
    From M 
      Left Join S1 On M_ID=S1_M_ID
      Left Join S2 On M_ID=S2_M_ID
    Group By M_ID
      

  3.   

    select M_ID, 
           M_Value1=isnull((select sum(s1_Value) from S1 Where S1_M_ID=M_ID),0),
           M_Value2=isnull((select sum(s2_Value) from S2 Where S2_M_ID=M_ID),0)
      From M
      

  4.   

    create view viewname
    as 
    select M_ID, 
           M_Value1=isnull((select sum(s1_Value) from S1 Where S1_M_ID=M.M_ID),0),
           M_Value2=isnull((select sum(s2_Value) from S2 Where S2_M_ID=M.M_ID),0)
      From M
      

  5.   

    create view viewname
    as 
    select M_ID, B.M_Value1, C.M_Value2
      From M A
      Left Join (select S1_M_ID, sum(s1_Value) M_Value1 from S1 group by S1_M_ID) B On A.M_ID=B.S1_M_ID
      Left Join (select S2_M_ID, sum(s2_Value) M_Value2 from S2 group by S2_M_ID) C On A.M_ID=C.S2_M_ID
     select A.M_ID, B.表一:M,包括一个字段,M_ID表二:S1,包括两个字段,S1_M_ID,S1_Value表三:S2,包括两个字段,S2_M_ID,S2_Value
      

  6.   

    哈哈,tj_dns(愉快的登山者) 的答案很有意思,不过是不是效率差一点点?