Skip to content
Advertisement

Sybase IQ 16 – Find members who have changed product

My data captures members purchasing history for a category of products. Typically a member will be buying product X for a number of months but I am interested in those members who moved to product Y and when that happened.

My data looks as follows:

I would like to pull a list of all member numbers and the first date they switched from preventative products to treatment products.

Please be aware I am using Sybase IQ and I don’t believe its possible run ordered sub-queries.

Advertisement

Answer

I would like to pull a list of all member numbers and the first date they switched from preventative products to treatment products.

Use lag() and group by:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement