Posts

Showing posts from February 26, 2019

Min/Max timestamp of a slow changing dimension

Image
2 2 I'm having some thoughts on an SQL (Redshift) query I need. So basically, I have the following table userid | timestamp | fruit 1 | 2018-12-10T14:46:50 | banana 1 | 2018-12-10T15:46:50 | banana 1 | 2018-12-10T16:46:50 | apple 1 | 2018-12-10T17:46:50 | banana Would it be possible to come up with a new table with the following information userid | start | end | fruit 1 | 2018-12-10T14:46:50 | 2018-12-10T16:46:50 | banana 1 | 2018-12-10T16:46:50 | 2018-12-10T17:46:50 | apple 1 | 2018-12-10T17:46:50 | | banana showing the time range where the user kept his favorite fruit selection. Thanks in advance! D sql amazon-redshift gaps-and-islands