sql - Filtering by analytic function results without subquery or subtable -


i'm working on netsuite project has limited sql capabilites. it's difficult test guessing sql building in gui.

i'd filter results of query results negative value of culmative sum.

is following valid pl/sql construct (barring small syntactical errors)?

 select sum(amount) over(partition itemid order date rows unbounded     preceding) "sum" table sum < 0 

secondly, due limitations in netsuite, following valid construct?

 select sum(amount) over(partition itemid order date rows unbounded      preceding) "sum" table sum(amount) over(partition itemid     order date rows unbounded preceding) < 0 

oracle's documentation suggests neither of these valid , filtering analytic function should done via subquery google groups , other websites suggest otherwise. using rank() , dense_rank() functions in examples may function differently.

to filter in on result of analytic functions have use inline views (subqueries in clause).

for example, query might like:

select  *    (             select  itemid,                     date,                     sum(amount) on (                                         partition itemid                                         order date                                         rows between unbounded preceding                                                  , current row                                      ) run_sum                table         )   run_sum < 0 

this show items, , associated dates, on running sum item less 0 (if there such dates given item).


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -