The pivot operator rotates a table so that the values in one column become new column headings. SQL tables are structured many ways and sometimes they need to be modified in a query for specific types of analysis.
We show a simple table structure with three columns along with sample data with insert statements. The first column is the foreign currency exchange symbol and the second is the date. The third column is the adjusted foreign currency exchange rate for that day.
The data is shown in the original format. Assume a different structure is required. Assume the first column will be the date and the rest of the columns will be a different exchange symbol. the intersection of every date and foreign exchange symbol then is the adjusted closing price
for that day.
A pivot operator will be used to make this transformation.
An aggregate is required for the pivot operator so we use MAX
but there is only one value anyway.