我是这么弄的,select b.buyer_uid c1,
round(sum(a.stock_sales_amnt),0) c3,
round((sum(a.stock_sales_amnt)-sum(a.stock_sales_amnt/a.sell_pr*a.old_nn_buy_price))/sum(a.stock_sales_amnt)*100,2) || '%' c2,
round(sum(a.stock_sales_amnt)/t1.amount,4)*100 ||'%' c4
from buyer b,article a tax t,
(select decode(sum(stock_sales_amnt),0,0.01,sum(stock_sales_amnt)) amount from article) t1
where a.buyer_uid=b.buyer_no
and t.vat_no=a.vat_no
group by b.buyer_uid
round(sum(a.stock_sales_amnt),0) c3,
round((sum(a.stock_sales_amnt)-sum(a.stock_sales_amnt/a.sell_pr*a.old_nn_buy_price))/sum(a.stock_sales_amnt)*100,2) || '%' c2,
round(sum(a.stock_sales_amnt)/t1.amount,4)*100 ||'%' c4
from buyer b,article a tax t,
(select decode(sum(stock_sales_amnt),0,0.01,sum(stock_sales_amnt)) amount from article) t1
where a.buyer_uid=b.buyer_no
and t.vat_no=a.vat_no
group by b.buyer_uid
解决方案 »
- 有了存储过程为什么还要用 SQL ?
- 使用PL SQL
- BAT调用ISQL命令报错
- 设置什末地方,可以实现对远程数据库的连接,不用标准的1521端口,用别的端口???(急)
- oracle 10g 的表中如何插入数据
- sql*plus怎么方向键无法使用?
- ORACLE数据拷贝出现乱码
- 因为是数据库的移值,导致表中double中的值有的为null,怎么一次性更新表中double类型的null值为0.0??
- 旧式的外联接语法有时会产生岐义,而SQL-92语法则可以避免,能否详细说明?
- 谁能告诉我这个SQL怎么写
- 数据文件如何导入到其他数据库
- 报错ORA-01652:无法通过128(在表空间TEMP)扩展TEMP段
比如说,你的SQL中,当amount为0时,需要C4的值是0还是其他值呢?
每个业务的要求可能是不一样的。
如果要求是0,可以这样写:
decode(t1.amount, 0, 0, round(sum(a.stock_sales_amnt)/t1.amount,4)*100 ||'%') c4