Q78 — AWS DEA-C01 Ch.1
Question 78 of 100 | ← Chapter 1
A company has a data warehouse that contains a table that is named Sales. The company stores the table in Amazon Redshift. The table includes a column that is named city_name. The company wants to query the table to find all rows that have a city_name that starts with "San" or "El". Which SQL query will meet this requirement?
- A. Select ∗ from Sales where city_name ~ ‘$(San|El)∗’;
- B. Select ∗ from Sales where city_name ~ ‘^(San|El)∗’; ✓
- C. Select ∗ from Sales where city_name ~’$(San&El)∗’;
- D. Select ∗ from Sales where city_name ~ ‘^(San&El)∗’;
Correct Answer: B. Select ∗ from Sales where city_name ~ ‘^(San|El)∗’;
Explanation
在这个SQL查询问题中,目标是选择所有城市名称以"San"或"El"开头的记录。在SQL中,使用正则表达式进行模糊匹配时,'^'代表字符串的开始,'