请问啊:有2个表 
表1 : ID       NAME       number        TYPE1       TYPE2
       1        转子           5          10*10        50MM表2 :  ID       TYPE1      TYPE2      price
       5         10*10      50MM       50查询条件是: 取表1中的TYPE1和TYPE2,如果和表2中的TYPE1和TYPE2相等,那么取出表2中的价格50 ,然后乘以表1 中的数量5这样的查询条件怎么写 ,谢谢 

解决方案 »

  1.   

    select
        a.Name,sum(a.Number*b.Price)
    from
        表1 a,表2 b
    where
        a.Type1=b.Type1 and a.Type2=b.Type2
    group by
        a.Name
      

  2.   

    select price*number from [表1] A Inner Join [表2] B on A.TYPE1=B.TYPE1 and A.TYPE2=B.TYPE2
      

  3.   

    select a.number*b.price as total
    from tb1 a inner join tb2 b
      on a.type1=b.type1 and a.type2=b.type2
      

  4.   

    select a.number*b.price
    from 表1 a,表2 b
    where a.type1= b.type1
    and a.type2 = b.type2
      

  5.   

    select number*price
    from 表1 a, 表2 b
    where a.TYPE1=b.TYPE1 and a.TYPE2=b.TYPE2 
      

  6.   

    declare @a table (ID int,name varchar(10),number int,type1 varchar(10),type2 varchar(10))
    insert into @a select 1,'转子',5,'10*10','50MM'
    declare @b table (id int,type1 varchar(10),type2 varchar(10),price int)
    insert into @b select 5,'10*10','50MM',50select a.*,number*price as '总价' from @a a,@b b 
    where a.TYPE1=b.type1 and a.type2=b.type2ID name number type1 type2 总价
    1 转子 5 10*10 50MM 250
      

  7.   

    select 2.type2*1.number   
    from 1,2 
    where 1.type1 = 2.type1 
    and 1.type2 = 2.type2