サブクエリーのSELECTステートメントを利用して次のテーブルから,Western Europeの中で
ドイツ語を母国語とする人口を算出するクエリーサンプル。
テーブルサンプル
Country には人口
CountryLanguageには言語毎の割合が%で入っている
select sum(tmp.German_Speakers) from
(
select (A.Population * B.Percentage) / 100 as 'German_Speakers'
from Country A, CountryLanguage B
where A.Region = 'Western Europe'
and A.Code = B.CountryCode
and B.Language = 'German'
) as tmp;