| 76 | --- |
| 77 | --- Przykład czasu wykonania etapów procedury o ID 28 i 29 |
| 78 | --- |
| 79 | SELECT sd.ptstnm, avg(s.fixdat - s.actdat) AS avarage, (extract(epoch FROM avg(s.fixdat - s.actdat))/3600)::int AS avhours, count (s.ptstid) AS liczba, s.ptstid AS ETAP_ID |
| 80 | FROM stages s |
| 81 | INNER JOIN stages_def sd USING(ptstid) |
| 82 | INNER JOIN procedures pr ON (pr.procid = s.procid OR s.procid = ANY (pr.pararr)) |
| 83 | INNER JOIN documents d ON (d.procid = pr.procid OR d.procid = pr.rootpr) |
| 84 | WHERE d.is_del IS FALSE AND d.gostof IS NULL |
| 85 | AND s.is_fix = TRUE |
| 86 | AND s.actdat IS NOT NULL |
| 87 | AND sd.prtpid IN (28, 29) |
| 88 | AND sd.is_del IS FALSE |
| 89 | AND sd.ptsttp IN ('ACTIVITY') |
| 90 | GROUP BY sd.ptstnm, s.ptstid, sd.ptsttp |
| 91 | ORDER BY avarage DESC |
| 92 | |
| 93 | |
| 94 | |