Link to home
Start Free TrialLog in
Avatar of sam2929
sam2929

asked on

roll up

Hi,
I have
Source:
Rq_id    event_id   event_code       cust number
1001        create          create              1005
1001         out              
1001         scucess       pickup             2001

So we want to roll up what we want is
Target will have just one row
Rq_id    event_id   event_code       cust number
1001       create         pickup               2001

So basic idea is pickup a row with event_id create and event_code pickup and cust number 2001 and then rollup it to one line only
Avatar of Sharath S
Sharath S
Flag of United States of America image

I don't understand fully. Do you want this?

select * from your_table where cust_number = 2001 and event_code = 'pickup'
ASKER CERTIFIED SOLUTION
Avatar of Kent Olsen
Kent Olsen
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sam2929
sam2929

ASKER

Thanks
what if i want sumthing like this
Source:
Rq_id    event_id   event_code       cust number        flag
1001        create          create              1005  
1001         out              
1001         sucess       pickup             2001      
1001         dump                                                                 Y

Result
Rq_id    event_id   event_code       cust number    flag
1001       create         pickup               2001            Y


Yep.  Just pick the correct fields (columns) from the query above.  Not sure how you're generating "flag".


Kent

SELECT t0.rq_id, t0.event_id, t1.event_code, t0.cust_number
FROM mytable t0
LEFT JOIN mytable t1
  ON t0.rq_id = t1.rq_id
 AND t0.event_id = 'create'
 AND t1.event_code = 'pickup'

Open in new window