0

当我在 oracle 数据库中有如下查询时,我将如何在 Netezza 数据库中重写相关查询...

select table1.column1,
case when table2.column2='xxxx' then
             ( select max(table3.column3) 
                  from table3  
                  where table3.column4=4 
                    and table3.column2=table1.column2 and
                        table3.column3=table4.column4
              ) 
else null
end
from table1,table2, table4.
4

1 回答 1

1

考虑改变结构。

SELECT table1.column1,
CASE WHEN table2.column2='xxxx' THEN
sub_tbl3.mx
ELSE NULL
END
FROM table1 inner join
     table2
     ON table1.column1=table2.column1 inner join
    table4
    ON table1.column2=table4.column4 left outer join
(SELECT table3.column2,
     table3.column3,
      MAX(table3.column3) AS mx
FROM table3
WHERE table3.column4=4
GROUP BY  table3.column2,
     table3.column3) sub_tbl3
ON table3.column2=table1.column2
AND table3.column3=table4.column4
于 2013-11-27T06:24:02.827 回答