again corrected view

This commit is contained in:
Jottyfan 2024-03-07 21:10:15 +01:00
parent 30e07c4bc7
commit a8082842c6

View File

@ -1,12 +1,12 @@
create or replace view public.v_camp as
with fbeds(used_beds_female, fk_camp) as (
with female(used, fk_camp) as (
select count(1), fk_camp
from t_person
where accept = true
and sex = 'female'
and camprole = 'student'
group by fk_camp
), mbeds(used_beds_male, fk_camp) as (
), male(used, fk_camp) as (
select count(1), fk_camp
from t_person
where accept = true
@ -30,9 +30,9 @@ with fbeds(used_beds_female, fk_camp) as (
c.beds_male,
c.blocked_beds_female,
c.blocked_beds_male,
mbeds.used_beds_male,
fbeds.used_beds_female
coalesce(male.used, 0) as used_beds_male,
coalesce(female.used, 0) as used_beds_female
from public.t_camp c
left join public.t_location l on c.fk_location = l.pk
left join mbeds on mbeds.fk_camp = c.pk
left join fbeds on fbeds.fk_camp = c.pk;
left join male on male.fk_camp = c.pk
left join female on female.fk_camp = c.pk;