Skip to content
Advertisement

SQL: CROSS JOIN over table partitions

I have the following table

What I would like to do is a cross join of the page_viewed column with itself but where the cross join is done on the partitions from session_id. So, from the table above the query would return:

I have looked into window functions today trying to find a way around it but it seems join functions cannot be used. Can anyone help?

Advertisement

Answer

You may join giving only the session_id as the join criteria:

enter image description here

Demo

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