select debet_balance from accounting_balance_tab where ACCOUNT=100120我想用case语句实现上面的where的功能,写了下面的语句,但是数据不对,请帮忙看一下错误,谢谢select case when ACCOUNT=100120 then debet_balance end debet_balance from accounting_balance_tab
select debet_balance from accounting_balance_tab where ACCOUNT=100120我想用case语句实现上面的where的功能,写了下面的语句,但是数据不对,请帮忙看一下错误,谢谢select case when ACCOUNT=100120 then debet_balance end debet_balance from accounting_balance_tab
select max(case when ACCOUNT=100120 then debet_balance end ) debet_balance from accounting_balance_tab
而且,这样去做性能上不划算,这样是全表扫描的
用WHERE可能可以用索引的
hebo2005 这个方法可以出来正确的数据,但是你出来的是其中的最大值,我要的是所有的数据
1001 2000
100120 3000
1001 1000
100120 5000我要写一个视图实现为这样
debet_balance1001 debet_balance100120
2000 3000
1000 5000
from(
select debet_balance debet_balance1001 ,rownum rnfrom accounting_balance_tab
where ACCOUNT =1001) a,
(
select debet_balance debet_balance10120 ,rownum rnfrom accounting_balance_tab
where ACCOUNT =100120) b
where a.rn=b.rn