QL查询语句问题
三个表工资表t1(工号num,基本工资basic,奖金bonus,出勤率rate, 实际月工资wage,年year,月month)
考勤表t2(工号num,出勤率rate,年year, 月month)
津贴表t3 (工号num.奖金bonus,年year,月month)
基本工资固定为1,实际月工资 = (基本工资+奖金)*出勤率
想要选择t2和t3中数据并算出对应的月工资 写入t1
insert into t1
select t2.num, 1, bonus, rate, (bonus+1)*rate, t2.year, t2.month
from t2, t3
where t2.year = t3.year and t2.month = t3.year and t2.num = t3.num
我自己写的得不到想要的结果,应该怎么写
where t2.year = t3.year and t2.month = t3.year and t2.num = t3.num
你这里写错了 应该是
where t2.year = t3.year and t2.month = t3.month and t2.num = t3.num 搜索条件有问题:
where t2.year = t3.year and t2.month = t3.month and t2.num = t3.num 建议写代码时,适当的格式化sql代码,这样方便你看出代码的错误 里面好几个错误啊,按照楼上的改吧
页:
[1]