Home > database >  By 201612 a department of the balance (CunXiu Hugh) last month - this month off work overtime this m
By 201612 a department of the balance (CunXiu Hugh) last month - this month off work overtime this m

Time:10-03

A is quite simple but the sooner the headache of a project, please understand the big brand, may have some more words, but still hope to have greatly for once!
First of all, I want to ask a department with master also is in the number of the department to hrs110ma extracted, through the department table corresponding to the superior department namely hrs009m3, through the table associated with the number of specific conditions to obtain some branch belongs to department and information, which is the following statement
PS: total hrs110ma personnel information table
Hrs009m3 corresponds to the superior departments table
Hrs390t0 employee monthly attendance record total file (query 2 leave, salaryid 3032 CunXiu last month and last month, 3033 take part within a table with a field to add)
Hrs351t0 overtime sheets (containing TRUM, overtime hours)
Hrs321t0 leave table (same as above, containing TRUM fields, namely off hours)
Probably means, a department of everyone hrs390t0 balances last month, count (salaryid field for 3032 and 3033 under the field the QTY of the value of the addition of the proceeds of the new QTY) - hrs351t0 overtime hours (TRUM fields) + hrs321t0 hours for leave (TRUM fields)=the balance this month, can become the new QTY field, the final query results, as long as display IDNO EMPLNM, EMPLNO, DEPTID, DEPTNM, QTY, YYYYMM (201612), FACTNO, trnsid

Select *
The from pec. Hrs110ma
Inner join pec. Hrs009m3 on pec. Hrs110ma. DEPTID=pec. Hrs009m3. DEPTID - DEPTID of several table department ID is the same, and IDNO ID number, EMPLNM employee name, EMPLNO staff number, name of DEPTNM department
Where SUP_DEPTID='00004199' - connecting the HRS009M3 SUP_DEPTID is superior departments code
='3300' and pec. Hrs110ma. Factno - factno is factory don't
And trnsid='1'; - whether trnsid representative on-the-job

The select IDNO EMPLNM, DEPTNM EMPLNO, DEPTNO, DEPTID
The from pec. Hrs110ma
Where stop_date is null
And trnsid=1
And deptid in (select deptid
The from pec. Hrs009m3
Where SUP_DEPTNO='01040000'
And factno='3300'
And stop_date is null) - this section of the statement and a period of effect is the same, stop_date is null and trnsid=1 is the same truth,

I didn't force, after the child associated useless, not the personnel to guide hrs390t0, this statement below is what I write, but the feeling is very wrong,,, because will not put the above information guide in there is no 3033 and 3032 together, this should be a wrong, I can send the hope not to mislead everyone a great god,
Select (pec) hrs390t0) QTY - pec. Hrs321t0. TNUM + pec. Hrs351t0. TNUM) as TNUM
The from PEC HRS390T0, PEC HRS321T0, PEC. HRS351T0
Where PEC. HRS390T0. QTY=PEC. HRS321T0. TNUM
And PEC. HRS351T0. TNUM=PEC. HRS321T0. TNUM
And pec. Hrs390T0. SALARYID='3032'

Word some more, still hope to have a great god help, obsessive-compulsive disorder and is not very will, come to consult, thank you.

CodePudding user response:

Is anyone here? The great god

CodePudding user response:

IDNO EMPLNM, EMPLNO DEPTID, DEPTNM, QTY, YYYYMM (201612), FACTNO, trnsid
These fields are belong to which table, please specify,

CodePudding user response:

 with 
T1 as
- the following employee information TAB
(select Anderson, DNO, a.E MPLNM, a. d. EPTNM, a.E MPLNO, a. d. EPTNO, a. d. EPTID
The from pec. Hrs110ma a
Inner join pec. Hrs009m3 b
On a. d. EPTID=b.D EPTID
Where b.S UP_DEPTID='00004199'
And b. actno='3300'
And a.t rnsid='1'
And b.s top_date is null)
T2 as
- this is the employee's last month balance hours TAB
(select/* + ordered */
Anderson, DNO, a.Q TY - b.T NUM + c.T NUM) as TNUM
The from (select t.I DNO, sum (t.Q TY) as QTY
The from PEC. HRS390T0 t
Where t.S ALARYID in (' 3032 ', '3033')
Group by t.I DNO). A, PEC. HRS321T0 b, PEC. HRS351T0 c
Where Anderson, DNO=b.I DNO
And b.I DNO=c.I DNO)
Select a t1. *, t2 TNUM from t1, t2 where t1. IDNO=t2. IDNO


I guess you are this kind of situation, as for YYYYMM (201612), FACTNO, trnsid the three fields, had not found out from which table,
  • Related