In this section you could find information about the select query syntax and its convertions.
Some parts in the output codes are omitted for clarity reasons.
Overall Select Translation
Simple select
Input Code:
IN -> Oracle_01.sql
select*from table1;select col1 from schema1.table1;
Output Code:
OUT -> Oracle_01.sql
select*fromtable1;select col1 fromschema1.table1;
Where clause
Input Code:
IN -> Oracle_02.sql
select col1 from schema1.table1 WHERE col1 =1and id >0or id <1;
Output Code:
OUT -> Oracle_02.sql
select col1 fromschema1.table1WHERE col1 =1and id >0or id <1;
Order By clause
Input Code:
IN -> Oracle_03.sql
select col1 from schema1.table1 order by id ASC;
Output Code:
OUT -> Oracle_03.sql
select col1 fromschema1.table1order by id ASC;
Group by
Input Code:
IN -> Oracle_04.sql
select col1 from schema1.table1 GROUP BY id;
Output Code:
OUT -> Oracle_04.sql
select col1 fromschema1.table1GROUP BY id;
Model Clause
The model clause is not supported yet.
Row Limiting Clause
Input Code:
IN -> Oracle_05.sql
-- Using ONLYselect*from TableFetch1 FETCHFIRST2ROWS ONLY;select*from TableFetch1 FETCHFIRST20 percent ROWS ONLY;select*from TableFetch1 order by col1 FETCHFIRST2ROWSwith ties;select*from TableFetch1 order by col1 FETCHFIRST20 percent ROWSwith ties;-- Using OFFSET clauseselect*from TableFetch1 offset 2rowsFETCHFIRST2ROWS ONLY;select*from TableFetch1 offset 2rowsFETCHFIRST60 percent rows ONLY;select*from TableFetch1 order by col1 offset 2rowsFETCHNEXT2ROWswith ties;select*from TableFetch1 order by col1 offset 2rowsFETCHFIRST60 percent ROWswith ties;-- Using WITH TIES clauseselect*from TableFetch1 FETCHFIRST2ROWSwith ties;select*from TableFetch1 FETCHFIRST20 percent ROWSwith ties;select*from TableFetch1 offset 2rowsFETCHNEXT2ROWswith ties;select*from TableFetch1 offset 2rowsFETCHFIRST60 percent ROWswith ties;-- Using ORDER BY clauseselect*from TableFetch1 order by col1 FETCHFIRST2ROWS ONLY;select*from TableFetch1 order by col1 FETCHFIRST20 percent ROWS ONLY;select*from TableFetch1 order by col1 offset 2rowsFETCHFIRST2ROWS ONLY;select*from TableFetch1 order by col1 offset 2rowsFETCHFIRST60 percent ROWS ONLY;select*from TableFetch1 FETCHFIRSTROWS ONLY;select*from TableFetch1 offset 2rows;
Output Code:
OUT -> Oracle_05.sql
-- Using ONLYselect*fromTableFetch1FETCHFIRST2ROWS ONLY;select*fromTableFetch1QUALIFY(ROW_NUMBER() OVER (ORDER BYNULL) -1) /COUNT(*) OVER () <20/100;select*fromTableFetch1QUALIFYRANK() OVER (order by col1) <=2;select*fromTableFetch1QUALIFY(RANK() OVER (order by col1) -1) /COUNT(*) OVER () <20/100;-- Using OFFSET clauseselect*fromTableFetch1offset 2rowsFETCHFIRST2ROWS ONLY;select*fromTableFetch1QUALIFY(ROW_NUMBER() OVER (ORDER BYNULL) -1-2) /COUNT(*) OVER () <60/100LIMITNULL OFFSET 2;select*fromTableFetch1QUALIFYRANK() OVER (order by col1) -2<=2LIMITNULL OFFSET 2;select*fromTableFetch1QUALIFY(RANK() OVER (order by col1) -1-2) /COUNT(*) OVER () <60/100LIMITNULL OFFSET 2;-- Using WITH TIES clauseselect*fromTableFetch1FETCHFIRST2ROWS ONLY;select*fromTableFetch1QUALIFY(ROW_NUMBER() OVER (ORDER BYNULL) -1) /COUNT(*) OVER () <20/100;select*fromTableFetch1offset 2rowsFETCHNEXT2ROWS ONLY;select*fromTableFetch1QUALIFY(ROW_NUMBER() OVER (ORDER BYNULL) -1-2) /COUNT(*) OVER () <60/100LIMITNULL OFFSET 2;-- Using ORDER BY clauseselect*fromTableFetch1order by col1FETCHFIRST2ROWS ONLY;select*fromTableFetch1QUALIFY(ROW_NUMBER() OVER (order by col1) -1) /COUNT(*) OVER () <20/100;select*fromTableFetch1order by col1 offset 2rowsFETCHFIRST2ROWS ONLY;select*fromTableFetch1QUALIFY(ROW_NUMBER() OVER (order by col1) -1-2) /COUNT(*) OVER () <60/100LIMITNULL OFFSET 2;select*fromTableFetch1FETCHFIRST1ROWS ONLY;select*fromTableFetch1LIMITNULL OFFSET 2;
In Oracle, the FETCH / OFFSET WITH TIES is ignored when no ORDER BY is specified in the SELECT. This case will be transformed to a FETCH / OFFSET with the ONLY keyword in Snowflake, please note that in Snowflake the ONLY keyword has no effect in the results and is used just for readability.
Pivot
Snowflake does not support the following statements:
- Rename columns
- Multiple Columns
Input Code:
IN -> Oracle_06.sql
select*from schema1.table1PIVOT(count(*) as count1 FOR (column1, column2) IN (row1 as rowName));
Output Code:
OUT -> Oracle_06.sql
select*fromschema1.table1!!!RESOLVE EWI!!! /*** SSC-EWI-0015 - PIVOT/UNPIVOT RENAME COLUMN NOT SUPPORTED ***/!!!!!!RESOLVE EWI!!! /*** SSC-EWI-0015 - PIVOT/UNPIVOT MULTIPLE COLUMN NOT SUPPORTED ***/!!!!!!RESOLVE EWI!!! /*** SSC-EWI-0015 - PIVOT/UNPIVOT RENAME COLUMN NOT SUPPORTED ***/!!!
PIVOT (count(*) FOR (column1, column2) IN ( row1));
Unpivot
Snowflake does not support the following statements:
- INCLUDE / EXCLUDE NULLS
Input Code:
IN -> Oracle_07.sql
select*from schema1.table1 UNPIVOT INCLUDENULLS (column1 FOR column2 IN (ANY, ANY));
Output Code:
OUT -> Oracle_07.sql
select*fromschema1.table1!!!RESOLVE EWI!!! /*** SSC-EWI-0015 - PIVOT/UNPIVOT INCLUDE NULLS NOT SUPPORTED ***/!!!UNPIVOT ( column1 FOR column2 IN (ANY,ANY));
Transformation of JOIN (+) to ANSI Syntax
This translation is currently deactivated and it's only meant for reference for translations done with previous versions of SnowConvert. For the current translation check the section above.
SnowConvert translates the NON-ANSI special outer join (+) syntax to ANSI outer join syntax. This subsection shows some examples:
To LEFT OUTER JOIN
Example 1:
Input Code:
IN -> Oracle_08.sql
-- Additional Params: --OuterJoinsToOnlyAnsiSyntaxSELECT d.department_name, e.employee_name FROM departments d, employees eWHERE d.department_id = e.department_id (+) AND d.department_id >=30;