Hi i d like some help please,
I need to count times per week, an employee has worked specific kind of duty, and i have managed that in the my query i have to calculate
work hours weekly. All i need is to join holiday dates (which are not on Saturday and Sunday) and fall same day employee worked this kind of duty.
I also managed to count those holidays per week. Here is the Sql..
SELECT Serialize("Qrevdomada","ΑΝΑ ΕΤΟΣ-ΜΗΝΑ",[ΑΝΑ ΕΤΟΣ-ΜΗΝΑ]) AS Serialize, DLookUp("[ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]","[hreosimerastbl]","[ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣID]=1") AS ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ, Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy-mm") AS [ΑΝΑ ΕΤΟΣ-ΜΗΝΑ], Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy") AS [ΑΝΑ ΕΤΟΣ], Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"mm") AS [ΑΝΑ ΜΗΝΑ], Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy-mm-ww") AS [ΑΝΑ ΕΒΔ], GetDaysInWeekMth([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ]) AS [ΑΡΙΘΜΟΣ ΗΜΕΡΩΝ ΕΒΔ], Count(IIf((Weekday([ΑΡΓΙΑ])<>1 And Weekday([ΑΡΓΙΑ])<>7),"0")) AS [ΑΡ ΑΡΓΙΩΝ], ypaliloitbl.ΥΠΑΛΛΗΛΟΣID, [ΑΡΙΘΜΟΣ ΗΜΕΡΩΝ ΕΒΔ]*[ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]-([ΑΡ ΑΡΓΙΩΝ]*([ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]+([ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]*(DLookUp("[ΧΡΕΩΣΗ%]","[harakthrismosypiresiontbl]","[ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣID]= 1")/100)))) AS [ΘΕΩΡΗΤΙΚΕΣ ΕΒΔΟΜΑΔΑΣ], ypaliloitbl.ΑΜ, ypiresiestbl.ΕΠΩΝΥΜΟID AS ΕΠΩΝΥΜΟ, [ΑΡ ΑΡΓΙΩΝ]*([ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]+([ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]*(DLookUp("[ΧΡΕΩΣΗ%]","[harakthrismosypiresiontbl]","[ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣID]= 1")/100))) AS ΣΥΝΘΗ, Count(IIf([ΕΙΔΟΣΥΠΗΡΕΣΙΑΣ]="ΒΡΑΧΕΙΑ ΑΔΕΙΑ",0,IIf([ΕΙΔΟΣΥΠΗΡΕΣΙΑΣ]="ΚΑΝΟΝΙΚΗ ΑΔΕΙΑ",0))) AS ΕΞΑΙΡΕΣΗ, [ΑΡΙΘΜΟΣ ΗΜΕΡΩΝ ΕΒΔ]*[ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]-([ΑΡ ΑΡΓΙΩΝ]*([ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]+([ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]*(DLookUp("[ΧΡΕΩΣΗ%]","[harakthrismosypiresiontbl]","[ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣID]= 1")/100)))) AS [ΘΕΩΡ ΩΡΕΣ ΥΠΑΛΛΗΛΟΥ], Count(IIf([ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣ]="ΤΑΚΤΙΚΕΣ",0,IIf([ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣ]="ΕΚΤΑΚΤΕΣ",0))) AS [ΗΜΕΡΕΣ ΕΡΓΑΣΙΑΣ], Count(IIf([ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣ]="ΕΙΔΙΚΕΣ ΑΔΕΙΕΣ",0)) AS [ΣΕ ΕΙΔ ΑΔΕΙΑ], Count(IIf([ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣ]="ΑΔΙΑΘΕΤΟ",0)) AS ΑΔΙΑΘΕΤΟ, Count(IIf([ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣ]="ΡΕΠΟ",0)) AS [ΣΕ ΡΕΠΟ], Count(IIf([ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣ]="ΚΩΛΥΟΜΕΝΟΙ",0)) AS ΚΩΛΗΘΗΚΕ, Count(IIf([ΧΡΕΩΣΗ]="ΧΡ ΚΥΡΙΑΚΗ",0)) AS [ΧΡ ΚΥΡΙΑΚΗ], Count(IIf([ΧΡΕΩΣΗ]="ΧΡ ΣΑΒΒΑΤΟ",0)) AS [ΧΡ ΣΑΒΒΑΤΟ], Sum(eidikeshreoseistbl.ΕΙΔΙΚΕΣΩΡΕΣ) AS [ΣΥΝΟΛΟ ΕΙΔΙΚΩΝ ΧΡΕΩΣΕΩΝ], ([ΣΥΝΟΛΟ ΕΙΔΙΚΩΝ ΧΡΕΩΣΕΩΝ])+Sum([ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]+([ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]*[ΧΡΕΩΣΗ%]/100)) AS [ΠΡΑΓΜΑΤΙΚΕΣ ΕΒΔΟΜΑΔΑΣ], ([ΠΡΑΓΜΑΤΙΚΕΣ ΕΒΔΟΜΑΔΑΣ])-([ΘΕΩΡ ΩΡΕΣ ΥΠΑΛΛΗΛΟΥ]) AS [ΔΙΑΦΟΡΑ ΣΕ ΩΡΕΣ]
FROM ypaliloitbl INNER JOIN (harakthrismosypiresiontbl INNER JOIN (eidiyphresiontbl INNER JOIN (eidikeshreoseistbl INNER JOIN (ypiresiestbl LEFT JOIN argiestbl ON ypiresiestbl.ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ = argiestbl.ΑΡΓΙΑ) ON eidikeshreoseistbl.ΕΙΔΙΚΗΧΡΕΩΣΗID = ypiresiestbl.ΧΡΕΩΣΗID) ON eidiyphresiontbl.ΕΙΔΟΣΥΠΗΡΕΣΙΑΣID = ypiresiestbl.ΕΙΔΟΣΥΠΗΡΕΣΙAΣID) ON harakthrismosypiresiontbl.ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣID = eidiyphresiontbl.ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣID) ON ypaliloitbl.ΥΠΑΛΛΗΛΟΣID = ypiresiestbl.ΕΠΩΝΥΜΟID
GROUP BY Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy-mm"), Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy"), Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"mm"), Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy-mm-ww"), GetDaysInWeekMth([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ]), ypaliloitbl.ΥΠΑΛΛΗΛΟΣID, ypaliloitbl.ΑΜ, ypiresiestbl.ΕΠΩΝΥΜΟID, Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy"), Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"mm")
HAVING (((ypaliloitbl.ΥΠΑΛΛΗΛΟΣID)<>58 And (ypaliloitbl.ΥΠΑΛΛΗΛΟΣID)<>60))
ORDER BY Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy-mm"), Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy"), Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"mm"), Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy-mm-ww");
epression [ΑΡ ΑΡΓΙΩΝ] returns times of holiday dates per week (not Sat & Sun)
expression [ΕΞΑΙΡΕΣΗ] returns times of empolyee worked spesific kind of duty
All i need in my query is to join and count the employee’s specific kind of duties with those holiday dates in the week.
If you consider helping me out i could explain
I need to count times per week, an employee has worked specific kind of duty, and i have managed that in the my query i have to calculate
work hours weekly. All i need is to join holiday dates (which are not on Saturday and Sunday) and fall same day employee worked this kind of duty.
I also managed to count those holidays per week. Here is the Sql..
SELECT Serialize("Qrevdomada","ΑΝΑ ΕΤΟΣ-ΜΗΝΑ",[ΑΝΑ ΕΤΟΣ-ΜΗΝΑ]) AS Serialize, DLookUp("[ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]","[hreosimerastbl]","[ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣID]=1") AS ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ, Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy-mm") AS [ΑΝΑ ΕΤΟΣ-ΜΗΝΑ], Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy") AS [ΑΝΑ ΕΤΟΣ], Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"mm") AS [ΑΝΑ ΜΗΝΑ], Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy-mm-ww") AS [ΑΝΑ ΕΒΔ], GetDaysInWeekMth([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ]) AS [ΑΡΙΘΜΟΣ ΗΜΕΡΩΝ ΕΒΔ], Count(IIf((Weekday([ΑΡΓΙΑ])<>1 And Weekday([ΑΡΓΙΑ])<>7),"0")) AS [ΑΡ ΑΡΓΙΩΝ], ypaliloitbl.ΥΠΑΛΛΗΛΟΣID, [ΑΡΙΘΜΟΣ ΗΜΕΡΩΝ ΕΒΔ]*[ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]-([ΑΡ ΑΡΓΙΩΝ]*([ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]+([ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]*(DLookUp("[ΧΡΕΩΣΗ%]","[harakthrismosypiresiontbl]","[ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣID]= 1")/100)))) AS [ΘΕΩΡΗΤΙΚΕΣ ΕΒΔΟΜΑΔΑΣ], ypaliloitbl.ΑΜ, ypiresiestbl.ΕΠΩΝΥΜΟID AS ΕΠΩΝΥΜΟ, [ΑΡ ΑΡΓΙΩΝ]*([ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]+([ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]*(DLookUp("[ΧΡΕΩΣΗ%]","[harakthrismosypiresiontbl]","[ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣID]= 1")/100))) AS ΣΥΝΘΗ, Count(IIf([ΕΙΔΟΣΥΠΗΡΕΣΙΑΣ]="ΒΡΑΧΕΙΑ ΑΔΕΙΑ",0,IIf([ΕΙΔΟΣΥΠΗΡΕΣΙΑΣ]="ΚΑΝΟΝΙΚΗ ΑΔΕΙΑ",0))) AS ΕΞΑΙΡΕΣΗ, [ΑΡΙΘΜΟΣ ΗΜΕΡΩΝ ΕΒΔ]*[ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]-([ΑΡ ΑΡΓΙΩΝ]*([ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]+([ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]*(DLookUp("[ΧΡΕΩΣΗ%]","[harakthrismosypiresiontbl]","[ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣID]= 1")/100)))) AS [ΘΕΩΡ ΩΡΕΣ ΥΠΑΛΛΗΛΟΥ], Count(IIf([ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣ]="ΤΑΚΤΙΚΕΣ",0,IIf([ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣ]="ΕΚΤΑΚΤΕΣ",0))) AS [ΗΜΕΡΕΣ ΕΡΓΑΣΙΑΣ], Count(IIf([ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣ]="ΕΙΔΙΚΕΣ ΑΔΕΙΕΣ",0)) AS [ΣΕ ΕΙΔ ΑΔΕΙΑ], Count(IIf([ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣ]="ΑΔΙΑΘΕΤΟ",0)) AS ΑΔΙΑΘΕΤΟ, Count(IIf([ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣ]="ΡΕΠΟ",0)) AS [ΣΕ ΡΕΠΟ], Count(IIf([ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣ]="ΚΩΛΥΟΜΕΝΟΙ",0)) AS ΚΩΛΗΘΗΚΕ, Count(IIf([ΧΡΕΩΣΗ]="ΧΡ ΚΥΡΙΑΚΗ",0)) AS [ΧΡ ΚΥΡΙΑΚΗ], Count(IIf([ΧΡΕΩΣΗ]="ΧΡ ΣΑΒΒΑΤΟ",0)) AS [ΧΡ ΣΑΒΒΑΤΟ], Sum(eidikeshreoseistbl.ΕΙΔΙΚΕΣΩΡΕΣ) AS [ΣΥΝΟΛΟ ΕΙΔΙΚΩΝ ΧΡΕΩΣΕΩΝ], ([ΣΥΝΟΛΟ ΕΙΔΙΚΩΝ ΧΡΕΩΣΕΩΝ])+Sum([ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]+([ΣΤΑΝΤΑΡΧΡΕΩΣΗΜΕΡΑΣ]*[ΧΡΕΩΣΗ%]/100)) AS [ΠΡΑΓΜΑΤΙΚΕΣ ΕΒΔΟΜΑΔΑΣ], ([ΠΡΑΓΜΑΤΙΚΕΣ ΕΒΔΟΜΑΔΑΣ])-([ΘΕΩΡ ΩΡΕΣ ΥΠΑΛΛΗΛΟΥ]) AS [ΔΙΑΦΟΡΑ ΣΕ ΩΡΕΣ]
FROM ypaliloitbl INNER JOIN (harakthrismosypiresiontbl INNER JOIN (eidiyphresiontbl INNER JOIN (eidikeshreoseistbl INNER JOIN (ypiresiestbl LEFT JOIN argiestbl ON ypiresiestbl.ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ = argiestbl.ΑΡΓΙΑ) ON eidikeshreoseistbl.ΕΙΔΙΚΗΧΡΕΩΣΗID = ypiresiestbl.ΧΡΕΩΣΗID) ON eidiyphresiontbl.ΕΙΔΟΣΥΠΗΡΕΣΙΑΣID = ypiresiestbl.ΕΙΔΟΣΥΠΗΡΕΣΙAΣID) ON harakthrismosypiresiontbl.ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣID = eidiyphresiontbl.ΧΑΡΑΚΤΗΡΙΣΜΟΣΥΠΗΡΕΣΙΑΣID) ON ypaliloitbl.ΥΠΑΛΛΗΛΟΣID = ypiresiestbl.ΕΠΩΝΥΜΟID
GROUP BY Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy-mm"), Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy"), Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"mm"), Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy-mm-ww"), GetDaysInWeekMth([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ]), ypaliloitbl.ΥΠΑΛΛΗΛΟΣID, ypaliloitbl.ΑΜ, ypiresiestbl.ΕΠΩΝΥΜΟID, Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy"), Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"mm")
HAVING (((ypaliloitbl.ΥΠΑΛΛΗΛΟΣID)<>58 And (ypaliloitbl.ΥΠΑΛΛΗΛΟΣID)<>60))
ORDER BY Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy-mm"), Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy"), Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"mm"), Format([ΗΜΕΡΑΥΠΗΡΕΣΙΑΣ],"yyyy-mm-ww");
epression [ΑΡ ΑΡΓΙΩΝ] returns times of holiday dates per week (not Sat & Sun)
expression [ΕΞΑΙΡΕΣΗ] returns times of empolyee worked spesific kind of duty
All i need in my query is to join and count the employee’s specific kind of duties with those holiday dates in the week.
If you consider helping me out i could explain