WITH RuСodes AS (
SELECT CountryCode Code
FROM countrylanguage
WHERE Language = 'Russian'
)
SELECT Name
FROM country
WHERE Code IN (
SELECT Code
FROM RuСodes
)
| Name |
| Azerbaijan |
| Belarus |
| Estonia |
| Finland |
| Georgia |
| Israel |
| Kazakstan |
| Kyrgyzstan |
| Lithuania |
| Latvia |
| ... |
| Common Table Expressions (CTE) are an easy way to split a complex SQL query into multiple queries, which gives you more flexibility and manageability. This query is similar to the example with the IN operator. A subquery that selects country codes that use Russian is placed in a temporary table, which is then used in the main query. |