Created
December 18, 2013 23:09
-
-
Save taylorkj/8031474 to your computer and use it in GitHub Desktop.
Here are a few Oracle to ANSI SQL translations I employed while working with an old Oracle script:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------------------------------------------------------------------------------ | |
-- Joins: | |
-- Oracle version: | |
SELECT | |
request.requestId | |
FROM | |
request, | |
incident, | |
changeRequest | |
WHERE | |
incident.requestId (+)= request.requestId | |
AND changeRequest.requestId (+)= request.requestId | |
-- ANSI SQL version: | |
SELECT | |
request.requestId | |
FROM | |
request | |
LEFT OUTER JOIN incident ON incident.requestId = request.requestId | |
LEFT OUTER JOIN changeRequest ON changeRequest.requestId = request.requestId | |
------------------------------------------------------------------------------------ | |
-- CASE Statements: | |
-- Oracle version: | |
decode(zaradap_report_type, 'H', 'Freshman', 'A', 'Transfer', zaradap_report_type) alevl | |
-- ANSI SQL version: | |
CASE zaradap_report_type WHEN 'H' THEN 'Freshman' | |
WHEN 'A' THEN 'Transfer' | |
ELSE zaradap_report_type END alevl | |
------------------------------------------------------------------------------------ | |
-- NULL value replacement: | |
--Oracle version: | |
nvl(sfrstcr_credit_hr, 0) | |
--TSQL version: | |
ISNULL(sfrstcr_credit_hr, 0) | |
--ANSI SQL: | |
COALESCE(sfrstcr_credit_hr, 0) | |
-- COALESCE can also handle a second field, as well as a default value if both fields are null: | |
COALESCE(email_address1, email_address2, 'no email address') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment