错误:架构" b"不存在

时间:2016-09-09 16:58:44

标签: postgresql

select a.gross, a.nett, a.cost,
    b.to_char(float8 (SUM(pymt+budget)*1000000)/(SUM(area)*40000),'FM999999999.00') AS xyz
FROM a, b
WHERE a.id=b.id 
AND id='123456';

为什么我一直收到此错误消息:

ERROR:  schema "b" does not exist
********** Error **********

ERROR: schema "b" does not exist
SQL state: 3F000

1 个答案:

答案 0 :(得分:1)

由于您的表to_char中不存在b,因此它会尝试在模式b中找到它:

b.to_char

只需删除b并使用它来限定列名:

to_char(
    float8 
        (SUM(b.pymt + a.budget) * 1000000) / 
        (SUM(b.area) * 40000)
    ,'FM999999999.00'
) AS xyz