三张表
student
学号 名 专业号
project
项目号 名 每小时钱
student&PrJ
学号 项目号 项目工时 第三个表关联一二个表, 项目费= 每小时钱* 项目工时让求每个系 每个项目的费用。呵呵,用sql语句不用程序啊
头疼死我了, 做不上。
student
学号 名 专业号
project
项目号 名 每小时钱
student&PrJ
学号 项目号 项目工时 第三个表关联一二个表, 项目费= 每小时钱* 项目工时让求每个系 每个项目的费用。呵呵,用sql语句不用程序啊
头疼死我了, 做不上。
T_project(pno,pname,money)
T_ps(sno,pno,hours)
select ts.dno,tp.pname,sum(hours*money) as total
from T_student as ts,T_projiect as tp,T_ps as tps
where ts.sno=tps.sno and tp.pno=tps.pno
group by ts.dno,tp.pname;
002 张三 电子
003 王二 计算机001 电力Mis 20
002 进出口ERP 30001 001 7
001 002 6
002 001 5
002 002 4
003 001 10
003 002 8
select c.spe_no,b.per_hour_mon * a.pro_hours cc from pro_stu a,project b,student c where a.stu_
= c.stu_no and a.pro_no=b.pro_no)
group by spe_no这个是大致的问题SQL> desc student
名称 是否为空? 类型
----------------------------------------- -------- ----------------------------
STU_NO VARCHAR2(10)
NAME VARCHAR2(20)
SPE_NO VARCHAR2(10)SQL> desc project
名称 是否为空? 类型
----------------------------------------- -------- ----------------------------
PRO_NO VARCHAR2(10)
PRO_NAME VARCHAR2(20)
PER_HOUR_MON NUMBERSQL> desc pro_stu
名称 是否为空? 类型
----------------------------------------- -------- ----------------------------
STU_NO VARCHAR2(10)
PRO_NO VARCHAR2(10)
PRO_HOURS NUMBER
select c.spe_no,b.per_hour_mon * a.pro_hours cc
from pro_stu a,project b,student c where a.stu_no
= c.stu_no and a.pro_no=b.pro_no)
group by spe_no