Ниже для BigQuery Standard SQL
#standardSQL
WITH table1 AS(
SELECT "America" AS country_name UNION ALL
SELECT "Germany" AS country_name UNION ALL
SELECT "England" AS country_name UNION ALL
SELECT "Nauru" AS country_name UNION ALL
SELECT "Brunei" AS country_name UNION ALL
SELECT "Kiribati" AS country_name UNION ALL
SELECT "Djibouti" AS country_name UNION ALL
SELECT "Malta" AS country_name
)
SELECT *
FROM table1
ORDER BY CASE
WHEN LOWER(SUBSTR(country_name, 1, 1)) IN ('a', 'g', 'e')
THEN CONCAT(' ', country_name) ELSE country_name
END
ожидаемый результат -
Row country_name
1 America
2 England
3 Germany
4 Brunei
5 Djibouti
6 Kiribati
7 Malta
8 Nauru
В случае, если вам нужны ТОЛЬКО те страны
#standardSQL
WITH table1 AS(
SELECT "America" AS country_name UNION ALL
SELECT "Germany" AS country_name UNION ALL
SELECT "England" AS country_name UNION ALL
SELECT "Nauru" AS country_name UNION ALL
SELECT "Brunei" AS country_name UNION ALL
SELECT "Kiribati" AS country_name UNION ALL
SELECT "Djibouti" AS country_name UNION ALL
SELECT "Malta" AS country_name
)
SELECT *
FROM table1
WHERE LOWER(SUBSTR(country_name, 1, 1)) IN ('a', 'g', 'e')
или
#standardSQL
WITH table1 AS(
SELECT "America" AS country_name UNION ALL
SELECT "Germany" AS country_name UNION ALL
SELECT "England" AS country_name UNION ALL
SELECT "Nauru" AS country_name UNION ALL
SELECT "Brunei" AS country_name UNION ALL
SELECT "Kiribati" AS country_name UNION ALL
SELECT "Djibouti" AS country_name UNION ALL
SELECT "Malta" AS country_name
)
SELECT *
FROM table1
WHERE REGEXP_CONTAINS(country_name, r'(?i)^(a|g|e)')
оба приведенных выше возврата:
Row country_name
1 America
2 Germany
3 England