0

我需要这样的查询,它是使用 sqlbuilder Java 函数生成的:

SELECT Sum(est_hu) / Sum( 
       total_hu) 
                 AS HU, 
       Max(year) AS YEAR 
FROM   b.counts BBCountsTable
WHERE  ( BBCountsTable.bg IN 
                (SELECT DISTINCT  
                BBSubTable.c_id 
                   FROM 
                  b.block 
                  BBSBlockSubTable 
                                         WHERE  ( ( 
                  BBBlockSubTable.id IN ( 3 ) ) ) )) )

但是,当子查询生成时,它会像这样创建它:

SELECT Sum(est_hu) / Sum( 
           total_hu) 
                     AS HU, 
           Max(year) AS YEAR 
    FROM   b.counts BBCountsTable, b.block 
                      BBSBlockSubTable 
    WHERE  ( BBCountsTable.bg IN 
                    (SELECT DISTINCT  
                    BBSubTable.c_id 
                       FROM 
                      b.block 
                      BBSBlockSubTable 
                                             WHERE  ( ( 
                      BBBlockSubTable.id IN ( 3 ) ) ) )) )

它会自动附加子查询表名称,即 b.block BBSBlockSubTable,因此查询不起作用。任何克服这个问题的建议都会有很大帮助。

4

1 回答 1

0

在这两个查询示例中,您都有一个无与伦比的额外 )。这将阻止他们首先工作!

于 2020-08-31T07:19:59.030 回答