sql interogation在3个表之间

时间:2016-11-09 13:04:46

标签: sql inner-join

我的问题是: 查找由contract_m.salar_baza+contract_j.onorar*contract_m.comision/100组成的总薪水 并且final结果包含名称和total_salarytables的结构是:

contract_m:
id_cm
comision
id_angajat

- 具有相同的值persoana.id_p salar_baza contract_j: id_cj onorar id_avocat - 具有相同的值persoana.id_p

Persoana id_p name

1 个答案:

答案 0 :(得分:0)

不,我在网上为我做了一些课程 我试试这个但不好 select persoana.nume, (select contract_m.salar_baza from contract_m inner join persoana on contract_m.id_angajat=persoana.id_p)+ (select contract_m.comision*contract_j.onorar from contract_m inner join contract_j on contract_m.id_angajat=contract_j.id_avocat) from persoana

我的表格格式是 CREATE TABLE "CONTRACT_J" ( "ID_CJ" NUMBER, "DATA" DATE, "OBIECT" VARCHAR2(12), "ONORAR" NUMBER, "EXEMPLARE" NUMBER, "ID_CLIENT" NUMBER, "ID_AVOCAT" NUMBER, CONSTRAINT "CONTRACT_J_CON" PRIMARY KEY ("ID_CJ") USING INDEX ENABLE ) /

CREATE TABLE "CONTRACT_M" ( "ID_CM" NUMBER, "DATA" DATE, "FUNCTIE" VARCHAR2(12), "SALAR_BAZA" NUMBER, "COMISION" NUMBER, "ID_ANGAJAT" NUMBER ) / CREATE TABLE "PERSOANA" ( "ID_P" NUMBER, "NUME" VARCHAR2(40), "ADRESA" VARCHAR2(12), "TELEFON" NUMBER, CONSTRAINT "PERSOANA_CON" PRIMARY KEY ("ID_P") USING INDEX ENABLE ) /