Skip to content
Advertisement

SQL SELECT with an extra column with more than 1 value

I have a table with column_1, column_2, column_3, and select it by:

What I want is to add an extra column ‘hour’, it would have 24 possible values from 0 to 23. The outcome is to have every row [column_1, column_2, column_3] repeated 24 times with all possible 24 values of the extra column hour:

How should I do it?

Advertisement

Answer

you can create a temp table or view with the hour values you want. Then you can join with that new hours view or table to repeat results. Here is my snippet, I just modified that answer :

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