select * from (
select (
select count(*)
from projects
where projects.team_id = '21bf170f-f37b-4bf9-838d-f66c5d10b385'
) as team_projects,
*
from teams
join team_members on team_members.team_id = teams.id
join (
select *
from plans
where id = 'basic'
) plans on plans.id = teams.plan_id
where user_id = auth.uid()
and teams.id = '21bf170f-f37b-4bf9-838d-f66c5d10b385'
and owner = true) as yo
where team_projects < allowed_projects
select * from (
select (
select count(*)
from projects
where projects.team_id = '21bf170f-f37b-4bf9-838d-f66c5d10b385'
) as team_projects,
*
from teams
join team_members on team_members.team_id = teams.id
join (
select *
from plans
where id = 'basic'
) plans on plans.id = teams.plan_id
where user_id = auth.uid()
and teams.id = '21bf170f-f37b-4bf9-838d-f66c5d10b385'
and owner = true) as yo
where team_projects < allowed_projects