Inner Join
Important Notice: Migration of Documentation Website
Please be advised that our documentation website is currently undergoing a migration to a new platform. To ensure you have access to the most up-to-date information, we kindly request that you visit our new documentation website located at:
Official Snowflake Snowconvert Documentation
For any immediate assistance or if you encounter any issues, please contact our support team at [email protected].
Thank you for your understanding.
Some parts in the output code are omitted for clarity reasons.
Description
An inner join (sometimes called a simple join) is a join of two or more tables that returns only those rows that satisfy the join condition. (Oracle SQL Reference Inner Join Subsection).
{ [ INNER ] JOIN table_reference
{ ON condition
| USING (column [, column ]...)
}
| { CROSS
| NATURAL [ INNER ]
}
JOIN table_reference
}
Sample Source Patterns
Order by clause added because the result order may vary between Oracle and Snowflake.
Since the result set is too large, Row Limiting Clause was added. You can remove this clause to retrieve the entire result set.
Check this section to set up the sample database.
Basic Inner Join
In the Inner Join clause "INNER" is an optional keyword, the following queries have two selects that retrieve the same data set.
Oracle
SELECT
*
FROM
hr.employees
INNER JOIN hr.departments ON
hr.departments.department_id = hr.employees.department_id
ORDER BY employee_id
FETCH NEXT 10 ROWS ONLY;
SELECT
*
FROM
hr.employees
JOIN hr.departments ON
hr.departments.department_id = hr.employees.department_id
ORDER BY employee_id
FETCH NEXT 10 ROWS ONLY;
|EMPLOYEE_ID|FIRST_NAME|LAST_NAME|EMAIL |PHONE_NUMBER|HIRE_DATE |JOB_ID |SALARY|COMMISSION_PCT|MANAGER_ID|DEPARTMENT_ID|DEPARTMENT_ID|DEPARTMENT_NAME|MANAGER_ID|LOCATION_ID|
|-----------|----------|---------|--------|------------|-----------------------|----------|------|--------------|----------|-------------|-------------|---------------|----------|-----------|
|100 |Steven |King |SKING |515.123.4567|2003-06-17 00:00:00.000|AD_PRES |24000 | | |90 |90 |Executive |100 |1700 |
|101 |Neena |Kochhar |NKOCHHAR|515.123.4568|2005-09-21 00:00:00.000|AD_VP |17000 | |100 |90 |90 |Executive |100 |1700 |
|102 |Lex |De Haan |LDEHAAN |515.123.4569|2001-01-13 00:00:00.000|AD_VP |17000 | |100 |90 |90 |Executive |100 |1700 |
|103 |Alexander |Hunold |AHUNOLD |590.423.4567|2006-01-03 00:00:00.000|IT_PROG |9000 | |102 |60 |60 |IT |103 |1400 |
|104 |Bruce |Ernst |BERNST |590.423.4568|2007-05-21 00:00:00.000|IT_PROG |6000 | |103 |60 |60 |IT |103 |1400 |
|105 |David |Austin |DAUSTIN |590.423.4569|2005-06-25 00:00:00.000|IT_PROG |4800 | |103 |60 |60 |IT |103 |1400 |
|106 |Valli |Pataballa|VPATABAL|590.423.4560|2006-02-05 00:00:00.000|IT_PROG |4800 | |103 |60 |60 |IT |103 |1400 |
|107 |Diana |Lorentz |DLORENTZ|590.423.5567|2007-02-07 00:00:00.000|IT_PROG |4200 | |103 |60 |60 |IT |103 |1400 |
|108 |Nancy |Greenberg|NGREENBE|515.124.4569|2002-08-17 00:00:00.000|FI_MGR |12008 | |101 |100 |100 |Finance |108 |1700 |
|109 |Daniel |Faviet |DFAVIET |515.124.4169|2002-08-16 00:00:00.000|FI_ACCOUNT|9000 | |108 |100 |100 |Finance |108 |1700 |
Snowflake
SELECT
*
FROM
hr.employees
INNER JOIN
hr.departments
ON
hr.departments.department_id = hr.employees.department_id
ORDER BY employee_id
FETCH NEXT 10 ROWS ONLY;
SELECT
*
FROM
hr.employees
JOIN
hr.departments
ON
hr.departments.department_id = hr.employees.department_id
ORDER BY employee_id
FETCH NEXT 10 ROWS ONLY;
|EMPLOYEE_ID|FIRST_NAME|LAST_NAME|EMAIL |PHONE_NUMBER|HIRE_DATE |JOB_ID |SALARY |COMMISSION_PCT|MANAGER_ID|DEPARTMENT_ID|DEPARTMENT_ID|DEPARTMENT_NAME|MANAGER_ID|LOCATION_ID|
|-----------|----------|---------|--------|------------|----------|----------|--------|--------------|----------|-------------|-------------|---------------|----------|-----------|
|100 |Steven |King |SKING |515.123.4567|2003-06-17|AD_PRES |24000.00| | |90 |90 |Executive |100 |1700 |
|101 |Neena |Kochhar |NKOCHHAR|515.123.4568|2005-09-21|AD_VP |17000.00| |100 |90 |90 |Executive |100 |1700 |
|102 |Lex |De Haan |LDEHAAN |515.123.4569|2001-01-13|AD_VP |17000.00| |100 |90 |90 |Executive |100 |1700 |
|103 |Alexander |Hunold |AHUNOLD |590.423.4567|2006-01-03|IT_PROG |9000.00 | |102 |60 |60 |IT |103 |1400 |
|104 |Bruce |Ernst |BERNST |590.423.4568|2007-05-21|IT_PROG |6000.00 | |103 |60 |60 |IT |103 |1400 |
|105 |David |Austin |DAUSTIN |590.423.4569|2005-06-25|IT_PROG |4800.00 | |103 |60 |60 |IT |103 |1400 |
|106 |Valli |Pataballa|VPATABAL|590.423.4560|2006-02-05|IT_PROG |4800.00 | |103 |60 |60 |IT |103 |1400 |
|107 |Diana |Lorentz |DLORENTZ|590.423.5567|2007-02-07|IT_PROG |4200.00 | |103 |60 |60 |IT |103 |1400 |
|108 |Nancy |Greenberg|NGREENBE|515.124.4569|2002-08-17|FI_MGR |12008.00| |101 |100 |100 |Finance |108 |1700 |
|109 |Daniel |Faviet |DFAVIET |515.124.4169|2002-08-16|FI_ACCOUNT|9000.00 | |108 |100 |100 |Finance |108 |1700 |
Inner Join with using clause
Oracle
SELECT
*
FROM
hr.employees
INNER JOIN hr.departments
USING(department_id)
ORDER BY employee_id
FETCH NEXT 10 ROWS ONLY;
|DEPARTMENT_ID|EMPLOYEE_ID|FIRST_NAME|LAST_NAME|EMAIL |PHONE_NUMBER|HIRE_DATE |JOB_ID |SALARY|COMMISSION_PCT|MANAGER_ID|DEPARTMENT_NAME|MANAGER_ID|LOCATION_ID|
|-------------|-----------|----------|---------|--------|------------|-----------------------|----------|------|--------------|----------|---------------|----------|-----------|
|90 |100 |Steven |King |SKING |515.123.4567|2003-06-17 00:00:00.000|AD_PRES |24000 | | |Executive |100 |1700 |
|90 |101 |Neena |Kochhar |NKOCHHAR|515.123.4568|2005-09-21 00:00:00.000|AD_VP |17000 | |100 |Executive |100 |1700 |
|90 |102 |Lex |De Haan |LDEHAAN |515.123.4569|2001-01-13 00:00:00.000|AD_VP |17000 | |100 |Executive |100 |1700 |
|60 |103 |Alexander |Hunold |AHUNOLD |590.423.4567|2006-01-03 00:00:00.000|IT_PROG |9000 | |102 |IT |103 |1400 |
|60 |104 |Bruce |Ernst |BERNST |590.423.4568|2007-05-21 00:00:00.000|IT_PROG |6000 | |103 |IT |103 |1400 |
|60 |105 |David |Austin |DAUSTIN |590.423.4569|2005-06-25 00:00:00.000|IT_PROG |4800 | |103 |IT |103 |1400 |
|60 |106 |Valli |Pataballa|VPATABAL|590.423.4560|2006-02-05 00:00:00.000|IT_PROG |4800 | |103 |IT |103 |1400 |
|60 |107 |Diana |Lorentz |DLORENTZ|590.423.5567|2007-02-07 00:00:00.000|IT_PROG |4200 | |103 |IT |103 |1400 |
|100 |108 |Nancy |Greenberg|NGREENBE|515.124.4569|2002-08-17 00:00:00.000|FI_MGR |12008 | |101 |Finance |108 |1700 |
|100 |109 |Daniel |Faviet |DFAVIET |515.124.4169|2002-08-16 00:00:00.000|FI_ACCOUNT|9000 | |108 |Finance |108 |1700 |
Snowflake
SELECT
*
FROM
hr.employees
INNER JOIN
hr.departments
USING(department_id)
ORDER BY employee_id
FETCH NEXT 10 ROWS ONLY;
|DEPARTMENT_ID|EMPLOYEE_ID|FIRST_NAME|LAST_NAME|EMAIL |PHONE_NUMBER|HIRE_DATE |JOB_ID |SALARY |COMMISSION_PCT|MANAGER_ID|DEPARTMENT_NAME|MANAGER_ID|LOCATION_ID|
|-------------|-----------|----------|---------|--------|------------|----------|----------|--------|--------------|----------|---------------|----------|-----------|
|90 |100 |Steven |King |SKING |515.123.4567|2003-06-17|AD_PRES |24000.00| | |Executive |100 |1700 |
|90 |101 |Neena |Kochhar |NKOCHHAR|515.123.4568|2005-09-21|AD_VP |17000.00| |100 |Executive |100 |1700 |
|90 |102 |Lex |De Haan |LDEHAAN |515.123.4569|2001-01-13|AD_VP |17000.00| |100 |Executive |100 |1700 |
|60 |103 |Alexander |Hunold |AHUNOLD |590.423.4567|2006-01-03|IT_PROG |9000.00 | |102 |IT |103 |1400 |
|60 |104 |Bruce |Ernst |BERNST |590.423.4568|2007-05-21|IT_PROG |6000.00 | |103 |IT |103 |1400 |
|60 |105 |David |Austin |DAUSTIN |590.423.4569|2005-06-25|IT_PROG |4800.00 | |103 |IT |103 |1400 |
|60 |106 |Valli |Pataballa|VPATABAL|590.423.4560|2006-02-05|IT_PROG |4800.00 | |103 |IT |103 |1400 |
|60 |107 |Diana |Lorentz |DLORENTZ|590.423.5567|2007-02-07|IT_PROG |4200.00 | |103 |IT |103 |1400 |
|100 |108 |Nancy |Greenberg|NGREENBE|515.124.4569|2002-08-17|FI_MGR |12008.00| |101 |Finance |108 |1700 |
|100 |109 |Daniel |Faviet |DFAVIET |515.124.4169|2002-08-16|FI_ACCOUNT|9000.00 | |108 |Finance |108 |1700 |
Cross Inner Join
Oracle
SELECT
*
FROM
hr.employees
CROSS JOIN hr.departments
ORDER BY department_name, employee_id
FETCH NEXT 10 ROWS ONLY;
|EMPLOYEE_ID|FIRST_NAME|LAST_NAME|EMAIL |PHONE_NUMBER|HIRE_DATE |JOB_ID |SALARY|COMMISSION_PCT|MANAGER_ID|DEPARTMENT_ID|DEPARTMENT_ID|DEPARTMENT_NAME|MANAGER_ID|LOCATION_ID|
|-----------|----------|---------|--------|------------|-----------------------|----------|------|--------------|----------|-------------|-------------|---------------|----------|-----------|
|100 |Steven |King |SKING |515.123.4567|2003-06-17 00:00:00.000|AD_PRES |24000 | | |90 |110 |Accounting |205 |1700 |
|101 |Neena |Kochhar |NKOCHHAR|515.123.4568|2005-09-21 00:00:00.000|AD_VP |17000 | |100 |90 |110 |Accounting |205 |1700 |
|102 |Lex |De Haan |LDEHAAN |515.123.4569|2001-01-13 00:00:00.000|AD_VP |17000 | |100 |90 |110 |Accounting |205 |1700 |
|103 |Alexander |Hunold |AHUNOLD |590.423.4567|2006-01-03 00:00:00.000|IT_PROG |9000 | |102 |60 |110 |Accounting |205 |1700 |
|104 |Bruce |Ernst |BERNST |590.423.4568|2007-05-21 00:00:00.000|IT_PROG |6000 | |103 |60 |110 |Accounting |205 |1700 |
|105 |David |Austin |DAUSTIN |590.423.4569|2005-06-25 00:00:00.000|IT_PROG |4800 | |103 |60 |110 |Accounting |205 |1700 |
|106 |Valli |Pataballa|VPATABAL|590.423.4560|2006-02-05 00:00:00.000|IT_PROG |4800 | |103 |60 |110 |Accounting |205 |1700 |
|107 |Diana |Lorentz |DLORENTZ|590.423.5567|2007-02-07 00:00:00.000|IT_PROG |4200 | |103 |60 |110 |Accounting |205 |1700 |
|108 |Nancy |Greenberg|NGREENBE|515.124.4569|2002-08-17 00:00:00.000|FI_MGR |12008 | |101 |100 |110 |Accounting |205 |1700 |
|109 |Daniel |Faviet |DFAVIET |515.124.4169|2002-08-16 00:00:00.000|FI_ACCOUNT|9000 | |108 |100 |110 |Accounting |205 |1700 |
Snowflake
SELECT
*
FROM
hr.employees
CROSS JOIN hr.departments
ORDER BY department_name, employee_id
FETCH NEXT 10 ROWS ONLY;
|EMPLOYEE_ID|FIRST_NAME|LAST_NAME|EMAIL |PHONE_NUMBER|HIRE_DATE |JOB_ID |SALARY |COMMISSION_PCT|MANAGER_ID|DEPARTMENT_ID|DEPARTMENT_ID|DEPARTMENT_NAME|MANAGER_ID|LOCATION_ID|
|-----------|----------|---------|--------|------------|----------|----------|--------|--------------|----------|-------------|-------------|---------------|----------|-----------|
|100 |Steven |King |SKING |515.123.4567|2003-06-17|AD_PRES |24000.00| | |90 |110 |Accounting |205 |1700 |
|101 |Neena |Kochhar |NKOCHHAR|515.123.4568|2005-09-21|AD_VP |17000.00| |100 |90 |110 |Accounting |205 |1700 |
|102 |Lex |De Haan |LDEHAAN |515.123.4569|2001-01-13|AD_VP |17000.00| |100 |90 |110 |Accounting |205 |1700 |
|103 |Alexander |Hunold |AHUNOLD |590.423.4567|2006-01-03|IT_PROG |9000.00 | |102 |60 |110 |Accounting |205 |1700 |
|104 |Bruce |Ernst |BERNST |590.423.4568|2007-05-21|IT_PROG |6000.00 | |103 |60 |110 |Accounting |205 |1700 |
|105 |David |Austin |DAUSTIN |590.423.4569|2005-06-25|IT_PROG |4800.00 | |103 |60 |110 |Accounting |205 |1700 |
|106 |Valli |Pataballa|VPATABAL|590.423.4560|2006-02-05|IT_PROG |4800.00 | |103 |60 |110 |Accounting |205 |1700 |
|107 |Diana |Lorentz |DLORENTZ|590.423.5567|2007-02-07|IT_PROG |4200.00 | |103 |60 |110 |Accounting |205 |1700 |
|108 |Nancy |Greenberg|NGREENBE|515.124.4569|2002-08-17|FI_MGR |12008.00| |101 |100 |110 |Accounting |205 |1700 |
|109 |Daniel |Faviet |DFAVIET |515.124.4169|2002-08-16|FI_ACCOUNT|9000.00 | |108 |100 |110 |Accounting |205 |1700 |
Natural Inner Join
Oracle
SELECT
*
FROM
hr.employees
NATURAL JOIN hr.departments
ORDER BY employee_id
FETCH NEXT 10 ROWS ONLY;
|MANAGER_ID|DEPARTMENT_ID|EMPLOYEE_ID|FIRST_NAME |LAST_NAME|EMAIL |PHONE_NUMBER|HIRE_DATE |JOB_ID |SALARY|COMMISSION_PCT|DEPARTMENT_NAME|LOCATION_ID|
|----------|-------------|-----------|-----------|---------|--------|------------|-----------------------|----------|------|--------------|---------------|-----------|
|100 |90 |101 |Neena |Kochhar |NKOCHHAR|515.123.4568|2005-09-21 00:00:00.000|AD_VP |17000 | |Executive |1700 |
|100 |90 |102 |Lex |De Haan |LDEHAAN |515.123.4569|2001-01-13 00:00:00.000|AD_VP |17000 | |Executive |1700 |
|103 |60 |104 |Bruce |Ernst |BERNST |590.423.4568|2007-05-21 00:00:00.000|IT_PROG |6000 | |IT |1400 |
|103 |60 |105 |David |Austin |DAUSTIN |590.423.4569|2005-06-25 00:00:00.000|IT_PROG |4800 | |IT |1400 |
|103 |60 |106 |Valli |Pataballa|VPATABAL|590.423.4560|2006-02-05 00:00:00.000|IT_PROG |4800 | |IT |1400 |
|103 |60 |107 |Diana |Lorentz |DLORENTZ|590.423.5567|2007-02-07 00:00:00.000|IT_PROG |4200 | |IT |1400 |
|108 |100 |109 |Daniel |Faviet |DFAVIET |515.124.4169|2002-08-16 00:00:00.000|FI_ACCOUNT|9000 | |Finance |1700 |
|108 |100 |110 |John |Chen |JCHEN |515.124.4269|2005-09-28 00:00:00.000|FI_ACCOUNT|8200 | |Finance |1700 |
|108 |100 |111 |Ismael |Sciarra |ISCIARRA|515.124.4369|2005-09-30 00:00:00.000|FI_ACCOUNT|7700 | |Finance |1700 |
|108 |100 |112 |Jose Manuel|Urman |JMURMAN |515.124.4469|2006-03-07 00:00:00.000|FI_ACCOUNT|7800 | |Finance |1700 |
Snowflake
SELECT
*
FROM
hr.employees
NATURAL JOIN
hr.departments
ORDER BY employee_id
FETCH NEXT 10 ROWS ONLY;
|MANAGER_ID|DEPARTMENT_ID|EMPLOYEE_ID|FIRST_NAME |LAST_NAME|EMAIL |PHONE_NUMBER|HIRE_DATE |JOB_ID |SALARY |COMMISSION_PCT|DEPARTMENT_NAME|LOCATION_ID|
|----------|-------------|-----------|-----------|---------|--------|------------|----------|----------|--------|--------------|---------------|-----------|
|100 |90 |101 |Neena |Kochhar |NKOCHHAR|515.123.4568|2005-09-21|AD_VP |17000.00| |Executive |1700 |
|100 |90 |102 |Lex |De Haan |LDEHAAN |515.123.4569|2001-01-13|AD_VP |17000.00| |Executive |1700 |
|103 |60 |104 |Bruce |Ernst |BERNST |590.423.4568|2007-05-21|IT_PROG |6000.00 | |IT |1400 |
|103 |60 |105 |David |Austin |DAUSTIN |590.423.4569|2005-06-25|IT_PROG |4800.00 | |IT |1400 |
|103 |60 |106 |Valli |Pataballa|VPATABAL|590.423.4560|2006-02-05|IT_PROG |4800.00 | |IT |1400 |
|103 |60 |107 |Diana |Lorentz |DLORENTZ|590.423.5567|2007-02-07|IT_PROG |4200.00 | |IT |1400 |
|108 |100 |109 |Daniel |Faviet |DFAVIET |515.124.4169|2002-08-16|FI_ACCOUNT|9000.00 | |Finance |1700 |
|108 |100 |110 |John |Chen |JCHEN |515.124.4269|2005-09-28|FI_ACCOUNT|8200.00 | |Finance |1700 |
|108 |100 |111 |Ismael |Sciarra |ISCIARRA|515.124.4369|2005-09-30|FI_ACCOUNT|7700.00 | |Finance |1700 |
|108 |100 |112 |Jose Manuel|Urman |JMURMAN |515.124.4469|2006-03-07|FI_ACCOUNT|7800.00 | |Finance |1700 |
Cross Natural Join
Oracle
SELECT
*
FROM
hr.employees
CROSS NATURAL JOIN hr.departments
ORDER BY employee_id
FETCH NEXT 10 ROWS ONLY;
|MANAGER_ID|DEPARTMENT_ID|EMPLOYEE_ID|FIRST_NAME |LAST_NAME|EMAIL |PHONE_NUMBER|HIRE_DATE |JOB_ID |SALARY|COMMISSION_PCT|DEPARTMENT_NAME|LOCATION_ID|
|----------|-------------|-----------|-----------|---------|--------|------------|-----------------------|----------|------|--------------|---------------|-----------|
|100 |90 |101 |Neena |Kochhar |NKOCHHAR|515.123.4568|2005-09-21 00:00:00.000|AD_VP |17000 | |Executive |1700 |
|100 |90 |102 |Lex |De Haan |LDEHAAN |515.123.4569|2001-01-13 00:00:00.000|AD_VP |17000 | |Executive |1700 |
|103 |60 |104 |Bruce |Ernst |BERNST |590.423.4568|2007-05-21 00:00:00.000|IT_PROG |6000 | |IT |1400 |
|103 |60 |105 |David |Austin |DAUSTIN |590.423.4569|2005-06-25 00:00:00.000|IT_PROG |4800 | |IT |1400 |
|103 |60 |106 |Valli |Pataballa|VPATABAL|590.423.4560|2006-02-05 00:00:00.000|IT_PROG |4800 | |IT |1400 |
|103 |60 |107 |Diana |Lorentz |DLORENTZ|590.423.5567|2007-02-07 00:00:00.000|IT_PROG |4200 | |IT |1400 |
|108 |100 |109 |Daniel |Faviet |DFAVIET |515.124.4169|2002-08-16 00:00:00.000|FI_ACCOUNT|9000 | |Finance |1700 |
|108 |100 |110 |John |Chen |JCHEN |515.124.4269|2005-09-28 00:00:00.000|FI_ACCOUNT|8200 | |Finance |1700 |
|108 |100 |111 |Ismael |Sciarra |ISCIARRA|515.124.4369|2005-09-30 00:00:00.000|FI_ACCOUNT|7700 | |Finance |1700 |
|108 |100 |112 |Jose Manuel|Urman |JMURMAN |515.124.4469|2006-03-07 00:00:00.000|FI_ACCOUNT|7800 | |Finance |1700 |
Snowflake
SELECT
*
FROM
hr.employees
NATURAL JOIN
hr.departments
ORDER BY employee_id
FETCH NEXT 10 ROWS ONLY;
|MANAGER_ID|DEPARTMENT_ID|EMPLOYEE_ID|FIRST_NAME |LAST_NAME|EMAIL |PHONE_NUMBER|HIRE_DATE |JOB_ID |SALARY |COMMISSION_PCT|DEPARTMENT_NAME|LOCATION_ID|
|----------|-------------|-----------|-----------|---------|--------|------------|----------|----------|--------|--------------|---------------|-----------|
|100 |90 |101 |Neena |Kochhar |NKOCHHAR|515.123.4568|2005-09-21|AD_VP |17000.00| |Executive |1700 |
|100 |90 |102 |Lex |De Haan |LDEHAAN |515.123.4569|2001-01-13|AD_VP |17000.00| |Executive |1700 |
|103 |60 |104 |Bruce |Ernst |BERNST |590.423.4568|2007-05-21|IT_PROG |6000.00 | |IT |1400 |
|103 |60 |105 |David |Austin |DAUSTIN |590.423.4569|2005-06-25|IT_PROG |4800.00 | |IT |1400 |
|103 |60 |106 |Valli |Pataballa|VPATABAL|590.423.4560|2006-02-05|IT_PROG |4800.00 | |IT |1400 |
|103 |60 |107 |Diana |Lorentz |DLORENTZ|590.423.5567|2007-02-07|IT_PROG |4200.00 | |IT |1400 |
|108 |100 |109 |Daniel |Faviet |DFAVIET |515.124.4169|2002-08-16|FI_ACCOUNT|9000.00 | |Finance |1700 |
|108 |100 |110 |John |Chen |JCHEN |515.124.4269|2005-09-28|FI_ACCOUNT|8200.00 | |Finance |1700 |
|108 |100 |111 |Ismael |Sciarra |ISCIARRA|515.124.4369|2005-09-30|FI_ACCOUNT|7700.00 | |Finance |1700 |
|108 |100 |112 |Jose Manuel|Urman |JMURMAN |515.124.4469|2006-03-07|FI_ACCOUNT|7800.00 | |Finance |1700 |
Natural Cross Join
Oracle
SELECT
*
FROM
hr.employees
NATURAL CROSS JOIN hr.departments
ORDER BY employee_id
FETCH NEXT 10 ROWS ONLY;
|EMPLOYEE_ID|FIRST_NAME|LAST_NAME|EMAIL|PHONE_NUMBER|HIRE_DATE |JOB_ID |SALARY|COMMISSION_PCT|MANAGER_ID|DEPARTMENT_ID|DEPARTMENT_ID|DEPARTMENT_NAME |MANAGER_ID|LOCATION_ID|
|-----------|----------|---------|-----|------------|-----------------------|-------|------|--------------|----------|-------------|-------------|----------------|----------|-----------|
|100 |Steven |King |SKING|515.123.4567|2003-06-17 00:00:00.000|AD_PRES|24000 | | |90 |10 |Administration |200 |1700 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17 00:00:00.000|AD_PRES|24000 | | |90 |100 |Finance |108 |1700 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17 00:00:00.000|AD_PRES|24000 | | |90 |90 |Executive |100 |1700 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17 00:00:00.000|AD_PRES|24000 | | |90 |80 |Sales |145 |2500 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17 00:00:00.000|AD_PRES|24000 | | |90 |70 |Public Relations|204 |2700 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17 00:00:00.000|AD_PRES|24000 | | |90 |60 |IT |103 |1400 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17 00:00:00.000|AD_PRES|24000 | | |90 |50 |Shipping |121 |1500 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17 00:00:00.000|AD_PRES|24000 | | |90 |40 |Human Resources |203 |2400 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17 00:00:00.000|AD_PRES|24000 | | |90 |30 |Purchasing |114 |1700 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17 00:00:00.000|AD_PRES|24000 | | |90 |20 |Marketing |201 |1800 |
Snowflake
SELECT
*
FROM
hr.employees
CROSS JOIN hr.departments
ORDER BY employee_id
FETCH NEXT 10 ROWS ONLY;
|EMPLOYEE_ID|FIRST_NAME|LAST_NAME|EMAIL|PHONE_NUMBER|HIRE_DATE |JOB_ID |SALARY |COMMISSION_PCT|MANAGER_ID|DEPARTMENT_ID|DEPARTMENT_ID|DEPARTMENT_NAME |MANAGER_ID|LOCATION_ID|
|-----------|----------|---------|-----|------------|----------|-------|--------|--------------|----------|-------------|-------------|----------------|----------|-----------|
|100 |Steven |King |SKING|515.123.4567|2003-06-17|AD_PRES|24000.00| | |90 |80 |Sales |145 |2500 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17|AD_PRES|24000.00| | |90 |20 |Marketing |201 |1800 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17|AD_PRES|24000.00| | |90 |60 |IT |103 |1400 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17|AD_PRES|24000.00| | |90 |70 |Public Relations|204 |2700 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17|AD_PRES|24000.00| | |90 |90 |Executive |100 |1700 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17|AD_PRES|24000.00| | |90 |30 |Purchasing |114 |1700 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17|AD_PRES|24000.00| | |90 |10 |Administration |200 |1700 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17|AD_PRES|24000.00| | |90 |100 |Finance |108 |1700 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17|AD_PRES|24000.00| | |90 |50 |Shipping |121 |1500 |
|100 |Steven |King |SKING|515.123.4567|2003-06-17|AD_PRES|24000.00| | |90 |40 |Human Resources |203 |2400 |
Known issues
1. Results ordering mismatch between languages
The result of the query will have the same content in both database engines but the order might be different if no Order By clause is defined in the query.
Related EWIs
No related EWIs.
Last updated