SQL “Dummy” Table, CTE and Pivot — Simple Example

Irakli DD
Jan 29, 2021

Create virtual “dummy” Table, for testing something in stydying process, you can make like this:

Dummy table name is earthquackes and columns is cDate and Magnitude.
Significant Earthquakes, 1965–2016

For using one table many times use temporary table function

;WITH - CTE common table expression

CTE Table

;WITH tablename as ( 0any select script select * from -) select * from tablename

u can also use convert function in last select convert(DATE, CTEearthquakes.cDate) as fDate

also, you can use CTE temporary tables many times by this ;WITH statement:

and in last select you can use all temporary tables, wich was created above, for example
make union from temporary tables, or join etc.

please see every steps of codes in my github:

https://gist.github.com/iraklidd/d4e69b008697ae501024d2aed6daf65a

--

--