0

I need a query like this, which is being generated using sqlbuilder Java functions:

SELECT Sum(prod) / Sum( 
       total_prod) 
                 AS PROD, 
       Max(year) AS YEAR 
FROM   b.sum SumTable
WHERE  ( SumTable.bg IN 
                (SELECT DISTINCT  
                SubSumTable.s_id 
                   FROM 
                  b.block 
                  SSumSubTable 
                                         WHERE  ( ( 
                  SSumSubTable.id IN ( 3 ) ) ) )) )

But instead when the subquery is generated it creates it like:

SELECT Sum(prod) / Sum( 
           total_prod) 
                     AS PROD, 
           Max(year) AS YEAR 
    FROM   b.sum SumTable, b.block 
                      SumTable 
    WHERE  ( SumTable.ab IN 
                    (SELECT DISTINCT  
                    SumTable.c_id 
                       FROM 
                      b.block 
                      SumSubTable 
                                             WHERE  ( ( 
                      SumSubTable.id IN ( 3 ) ) ) )) )

It automatically appends the subquery table name i.e b.block SubSumTable because of which the query is not working. Any suggestion to overcome this would be a great help.

CoderBeginner
  • 717
  • 1
  • 12
  • 39

1 Answers1

0

You have an unmatched extra ) in both those query examples. That would prevent them working in the first place!

user9601310
  • 1,076
  • 1
  • 7
  • 12