SQL Alternative to Virtual Table using “With” Keyword

Let’s say I have a table called States with the following columns and data.

StateTable

Now let’s say I need to create a virtual table that consists of the ID and Abbreviation columns only.  I can do this by using the “with” keyword.  Here’s an example:

with myVirtualTable as (
Select ID, Abbreviation
From States
)

select * From myVirtualTable

Here are the results:

results

need

Advertisements