This is an interesting way to build a SQL table. It might be useful when writing some sample code.
Instead of using create table and insert rows this simple sql does it all to create a temp table:
SELECT col1, col2
FROM (VALUES ('January', 1),('Feburary', 2),('March', 3),('April', 4),('May', 5)) AS tbl(col1, col2)
See the WHERE clause to see a way to referencing the temp table:
SELECT col1, col2
FROM (VALUES ('January', 1),('Feburary', 2),('March', 3),('April', 4),('May', 5)) AS tbl(col1, col2)
WHERE tbl.col1 = 'January'
No comments:
Post a Comment