'Error relation does not exist SQL WITH on POSTGRESQL

I get ERROR: relation "case_avg" does not exist in my sql request

    with case_avg AS
                (select
                               avg(vv.total_vcpu) as avgvcpu,
                               avg(vv.total_vram) as avgvram,
                               avg(vv.total_hdd) as avghdd,
                               pod,
                               report_date
                from common.vmware_vm vv
                group by pod,report_date)

select
    (ca.avgvcpu-v.total_vcpu) as vcpu,
    (ca.avgvram-v.total_vram) as vram,
    (ca.avghdd-v.total_hdd) as hdd,
    Concat(lower(v.vdc),lower(v.org)) as org_vdc
from
    common.vmware_vm v
inner join case_avg  ca on
    ca.pod = v.pod and ca.report_date = v.report_date 
group by org_vdc 

How i can resolve this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source