如decode(字段名,'sql语句',字段名,0)比如 登录用户的ID是可以得到的,session('登录用户ID')
想实现:
max(decode(字段名,'sql语句取出不等于登录用户的ID',字段名,0))
min(decode(字段名,'sql语句取出不等于登录用户的ID',字段名,0))
或者,是否可以实现,如某价格表,
用户自己的价格 其他用户价格(最高) 其他用户价格(最低)
---------------------------------------------------------实现以上数据列表形式,用decode()如何实现。谢谢

解决方案 »

  1.   

    原表为t(username,price)select username2 ,price,
    (case  when price=price2 then (select max(price) from t where username<>username2) else price2 end) as "其它用户最大值",
    (case  when price=price3 then (select min(price) from t where username<>username2) else price3 end) as "其它用户最小值"
    from (select username as username2,price,(select max(price) from t) price2,(select min(price) from t) price3 from t a) c;
      

  2.   

    select decode(1,1,(select 2 from dual),3) from dualmax(decode(字段名,(sql语句取出不等于登录用户的ID),字段名,0))
    min(decode(字段名,(sql语句取出不等于登录用户的ID),字段名,0))把‘’换成()
      

  3.   

    sasacat(傻傻猫) 是9i的,但我用的是8i。谢谢