计算小计

BREAK ON: 可以让SQL*Plus根据列值的范围分割输出结果
COMPUTE: 可以让SQL*Plus计算一列的值
 
例:
BREAK ON product_type_id
COMPUTE SUM OF price ON product_type_id
SET ECHO OFF
SET VERIFY OFF
SET PAGESIZE 50
SET LINESIZE 70
CLEAR COLUMNS
COLUMN price HEADING Price FORMAT $999.99
SELECT product_type_id,name,price
FROM products
ORDER BY product_type_id;
CLEAR COLUMNS
 
SQL> @run
PRODUCT_TYPE_ID NAME                          Price              
--------------- ------------------------------ --------              
                                    1 Modern Science        $19.95              
                                       Chemistry                   $30.00              
***************                                                     --------              
sum                                                                     $49.95              
                                   2  Z Files                          $49.99              
                                       Tank War                      $13.95              
                                       Supernova                    $25.99              
                                       2412: The Return         $14.95              
***************                                                      --------              
sum                                                                      $104.88              
                                      3 Space Force 9            $13.49              
                                      From Another Planet     $12.99              
***************                                                      --------               
sum                                                                       $26.48              
                                     4 Classical Music          $10.99              
                                         Pop 3                            $15.99              
                                        Creative Yell                 $14.99               
***************                                                        --------              
sum                                                                       $41.97              
                                        My Front Line               $13.49              
***************                                                       --------              
sum                                                                      $13.49              

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17014649/viewspace-600891/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/17014649/viewspace-600891/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值