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?

Correct Answer: B. Select ∗ from Sales where city_name ~ ‘^(San|El)∗’;

Explanation

在这个SQL查询问题中,目标是选择所有城市名称以"San"或"El"开头的记录。在SQL中,使用正则表达式进行模糊匹配时,'^'代表字符串的开始,' 代表字符串的结束,'|'代表逻辑或。因此,正确的正则表达式应该是'^(San|El)*',它表示匹配所有以"…" />

代表字符串的结束,'|'代表逻辑或。因此,正确的正则表达式应该是'^(San|El)*',它表示匹配所有以"…" />
代表字符串的结束,'|'代表逻辑或。因此,正确的正则表达式应该是'^(San|El)*',它表示匹配所有以"…" />
代表字符串的结束,'|'代表逻辑或。因此,正确的正则表达式应该是'^(San|El)*',它表示匹配所有以"San"或"El"开头的字符串。选项B中的查询语句正是使用了这个正则表达式,所以B是正确的答案。

代表字符串的结束,'|'代表逻辑或。因此,正确的正则表达式应该是'^(San|El)*',它表示匹配所有以"…" />
代表字符串的结束,'|'代表逻辑或。因此,正确的正则表达式应该是'^(San|El)*',它表示匹配所有以"…" />
代表字符串的结束,'|'代表逻辑或。因此,正确的正则表达式应该是'^(San|El)*',它表示匹配所有以"…" />