sql - Oracle: Select using compound key from subquery -


so here's situation- our records use compound key of name/date. want see names have performed 2 specific actions in row, want like

 select name   (select name n, date d table action='action1'),  (select name table name = n , date > d , action='action2' , rownum=1 order date desc) 

but counts n , d invalid identifiers. how can need?

analytical functions perfect sort of thing.... disclaimer quick , dirty , column names little misleading. lag/lead options want play with

http://sqlfiddle.com/#!4/bd7b2/7

select name,thedate,theaction,prev_action,prev_date   (  select name,thedate,theaction,  lag(theaction) on (partition name order thedate,theaction) prev_action, lag(thedate) on (partition name order thedate,theaction) prev_date table1  order name,thedate,theaction ) theaction = 'action1' , prev_action = 'action2' ; 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -