The following is an example of a table using the WITH clause as a source to the pivot query.
SELECT * FROM (with temp as (select * from s1) select * from temp)dt PIVOT (SUM(sales) FOR mon IN ('Jan','Feb', 'Mar'))tmp;
Result:
*** Query completed. 3 rows found. 4 columns returned. *** Total elapsed time was 1 second. yr Jan Feb Mar ----- ------ ------ ------- 2001 100 110 120 2002 150 200 250 2003 300 310 ?