ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 计算小计

计算小计

原创 Linux操作系统 作者:xw_z 时间:2009-05-24 11:22:24 0 删除 编辑
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/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 使用变量
请登录后发表评论 登录
全部评论

注册时间:2009-05-22

  • 博文量
    28
  • 访问量
    38909