SELECT d.UID, d.nr, d.len, d.lenWeight, f.nr AS nrFree, f.len AS lenFree, d.lenWeight - COALESCE(f.len, 0) as lenReal
SELECT d.UID, d.nr, d.len, d.lenWeight, f.nr AS nrFree, f.len AS lenFree, d.lenWeight - COALESCE(f.len, 0) as lenReal
FROM
FROM
(SELECT e.UID, COUNT(s.Len) as nr, SUM(s.Len) as len, SUM( s.Len*(1+(((HOUR(s.DateS)+2)%24)<10and((HOUR(s.DateE)+2)%24)<10)))aslenWeightFROM`Shifts`ASsINNERJOIN`ShiftEntry`ASeUSING(SID)WHERENOTUID=0GROUPBYUID)asd
(SELECT e.UID, COUNT(s.Len) as nr, SUM(s.Len) as len, SUM( s.Len*(1+(((HOUR(s.DateS)+2)%24)<10and((HOUR(s.DateE)+2)%24)<=10)))aslenWeightFROM`Shifts`ASsINNERJOIN`ShiftEntry`ASeUSING(SID)WHERENOTUID=0GROUPBYUID)asd
LEFT JOIN
LEFT JOIN
(SELECT UID, COUNT(Length) AS nr, SUM(Length) AS len FROM `ShiftFreeloader` GROUP BY UID) AS f
(SELECT UID, COUNT(Length) AS nr, SUM(Length) AS len FROM `ShiftFreeloader` GROUP BY UID) AS f
"SELECT COUNT(*) AS `Count [x]`, SUM(Shifts.Len) as `Sum [h]` from Shifts LEFT JOIN ShiftEntry USING(SID) WHERE (ShiftEntry.UID!=0)");
echo "<br>\n";
funktion_db_element_list_2row( "Geleisteter Arbeit (Ohne Raum aufabau (RID=7)",
"SELECT COUNT(*) AS `Count [x]`, SUM(Shifts.Len) as `Sum [h]` from Shifts LEFT JOIN ShiftEntry USING(SID) WHERE (ShiftEntry.UID!=0) AND (Shifts.RID!=7)");