CJCoding With Joseph
15free / daySign inCreate account

Months One to Twelve

Use a recursive CTE named months with a single column n to generate the numbers 1 to 12 without reading any table: the anchor selects 1, and the recursive step adds 1 to the previous row while n is below 12. Return one column aliased month, sorted ascending.

Expected result:

+-------+
| month |
+-------+
|     1 |
|     2 |
|     3 |
|     4 |
|     5 |
|     6 |
|     7 |
|     8 |
|     9 |
|    10 |
+-------+
(showing 10 of 12 rows)
Hints3 available
Topics:
CTEs
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (sel, ins, desc)

Results

Run your SQL to see every statement's output here, then how it compares with the expected answer.

Not sure what is in a table? SHOW TABLES lists them and DESCRIBE students shows the columns — or open the database browser on the left.