请问啊:有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 : 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这样的查询条件怎么写 ,谢谢
解决方案 »
- 有一张 员工工资表(salary),表有三列:员工编号(id),工资(salary)
- 总结一下,免得每次都得去查看别人的东西(日期函数)
- 怎样查出或删除表中相同的记录
- sql select a as b from tbl_a 要求b是tbl_a中一个字段如何实现
- win2003中SQL2000使用临时表中文即出现乱码,不使用没有问题
- sql server2000有哪些数据类型。相应的汉语意思是什么?
- 关于时间的操作
- 请问怎样用select将用户表的结构输出到EXECL表中?表比较多,手工太麻烦了,请有经验的帮帮忙
- 我想把这些记录显示出来的SQL语句怎么写啊?
- SQLSERVER2000版本双击一表名获得表的记录数与实际的记录不符
- 寻找一条SQL语句!
- I/O成本?
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
from tb1 a inner join tb2 b
on a.type1=b.type1 and a.type2=b.type2
from 表1 a,表2 b
where a.type1= b.type1
and a.type2 = b.type2
from 表1 a, 表2 b
where a.TYPE1=b.TYPE1 and a.TYPE2=b.TYPE2
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
from 1,2
where 1.type1 = 2.type1
and 1.type2 = 2.type2