AlisdairO / pgexercises

PostgreSQL Exercises web site code
Other
400 stars 62 forks source link

00060000-fachours3.ex solution does not suggest the `trunc` function #80

Open eldad opened 9 months ago

eldad commented 9 months ago

First of all - Great set of exercises, many thanks for that!

I noticed that the solution for 00060000-fachours3.ex uses char formatting (which I did not think of while solving it) and I was wondering if there is a reason for leaving out the (for me) obvious way to apply trunc(<value>, 2). If not, could this be included? I would also be happy to contribute a PR, just let me know.

For example:

select f.facid, f.name, trunc(sum(b.slots / 2.0), 2)
    from
    cd.facilities f join cd.bookings b
        on b.facid = f.facid
group by 1,2
order by 1;

BTW - for the dataset, trunc and round yield the same results.