again corrected view
This commit is contained in:
parent
30e07c4bc7
commit
a8082842c6
@ -1,12 +1,12 @@
|
|||||||
create or replace view public.v_camp as
|
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
|
select count(1), fk_camp
|
||||||
from t_person
|
from t_person
|
||||||
where accept = true
|
where accept = true
|
||||||
and sex = 'female'
|
and sex = 'female'
|
||||||
and camprole = 'student'
|
and camprole = 'student'
|
||||||
group by fk_camp
|
group by fk_camp
|
||||||
), mbeds(used_beds_male, fk_camp) as (
|
), male(used, fk_camp) as (
|
||||||
select count(1), fk_camp
|
select count(1), fk_camp
|
||||||
from t_person
|
from t_person
|
||||||
where accept = true
|
where accept = true
|
||||||
@ -30,9 +30,9 @@ with fbeds(used_beds_female, fk_camp) as (
|
|||||||
c.beds_male,
|
c.beds_male,
|
||||||
c.blocked_beds_female,
|
c.blocked_beds_female,
|
||||||
c.blocked_beds_male,
|
c.blocked_beds_male,
|
||||||
mbeds.used_beds_male,
|
coalesce(male.used, 0) as used_beds_male,
|
||||||
fbeds.used_beds_female
|
coalesce(female.used, 0) as used_beds_female
|
||||||
from public.t_camp c
|
from public.t_camp c
|
||||||
left join public.t_location l on c.fk_location = l.pk
|
left join public.t_location l on c.fk_location = l.pk
|
||||||
left join mbeds on mbeds.fk_camp = c.pk
|
left join male on male.fk_camp = c.pk
|
||||||
left join fbeds on fbeds.fk_camp = c.pk;
|
left join female on female.fk_camp = c.pk;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user