Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1798985
  • 博文数量: 334
  • 博客积分: 11301
  • 博客等级: 上将
  • 技术积分: 3452
  • 用 户 组: 普通用户
  • 注册时间: 2006-10-18 10:19
个人简介

路虽弥,不行不至;事虽少,不做不成。

文章分类

全部博文(334)

文章存档

2013年(4)

2012年(19)

2011年(27)

2010年(71)

2009年(45)

2008年(15)

2007年(84)

2006年(69)

分类: Oracle

2010-05-31 11:52:30

 

Oracle Analysis Function

 

FUNCTION_NAME(,...) OVER()

 

SELECT t.transaction_date,

       t.item_id,

       t.quantity,

       SUM(decode(t.transaction_type, 'RETRUN TO RECEIVING', -1 * t.quantity, t.quantity)) over(PARTITION BY t.item_id ORDER BY trunc(t.transaction_date)) Accumulative1,

       SUM(decode(t.transaction_type, 'RETRUN TO RECEIVING', -1 * t.quantity, t.quantity)) over(PARTITION BY t.item_id ORDER BY trunc(t.transaction_date) range between unbounded preceding and current row) Accumulative2,

       rank() over(ORDER BY trunc(t.transaction_date)) rank1,

       dense_rank() over(ORDER BY trunc(t.transaction_date)) rank2,

       row_number() over(ORDER BY trunc(t.transaction_date)) rank3

  FROM (SELECT a.quantity,

               pla.item_id,

               a.transaction_date,

               pla.po_line_id,

               a.organization_id,

               a.transaction_type,

               a.transaction_id

          FROM po.rcv_transactions a, po_lines_all pla

         WHERE a.po_line_id = pla.po_line_id(+)

           AND pla.item_ID = 210643

           AND a.organization_id = 216

           and a.destination_type_code = 'INVENTORY'

           AND a.SOURCE_DOCUMENT_CODE = 'PO') t

 

 

 

 

 

阅读(1387) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~