| 34 | |
| 35 | }}} |
| 36 | |
| 37 | === Преференца на клиентот за број на денови според неговите објави за Travel Health полиса за минатата година во опаѓачки редослед === |
| 38 | |
| 39 | {{{#!sql |
| 40 | |
| 41 | select |
| 42 | 'Travel Health' as Typepolicy, |
| 43 | COUNT(*) AS posts_count, |
| 44 | (p.edate::DATE - p.sdate::DATE) AS average_days_preference |
| 45 | FROM |
| 46 | project."policy" as p |
| 47 | JOIN |
| 48 | project.Pol_travel AS Pt ON p.p_id = Pt.pol_id |
| 49 | WHERE |
| 50 | EXTRACT(YEAR FROM p.edate) = EXTRACT(YEAR FROM CURRENT_DATE) - 1 |
| 51 | GROUP BY |
| 52 | average_days_preference |
| 53 | order by average_days_preference desc |