DEA-C01 Exam QuestionsBrowse all questions from this exam

DEA-C01 Exam - Question 95


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?

Show Answer
Correct Answer: B

To find all rows in the Sales table where the city_name starts with 'San' or 'El', you should use a regular expression pattern that matches either 'San' or 'El' at the beginning of the string. The correct SQL query is: Select * from Sales where city_name ~ '^(San|El)'. Here, the caret (^) asserts the position at the start of the string, and (San|El) matches either 'San' or 'El'.

Discussion

5 comments
Sign in to comment
JohnYangOption: B
Jun 19, 2024

^ asserts the position at the start of the string. (San|El) matches either "San" or "El".

tgvOption: B
Jun 15, 2024

~: This operator indicates the use of a regular expression. ^: This symbol signifies the start of the string. (San|El): This pattern matches strings that start with either "San" or "El".

HunkyBunkyOption: B
Jun 21, 2024

B - becuase of regexp

bakarysOption: B
Jul 2, 2024

B. Select * from Sales where city_name ~ ‘^(San|El)*’; This query uses a regular expression pattern with the ~ operator. The caret ^ at the beginning of the pattern indicates that the match must start at the beginning of the string. (San|El) matches either “San” or “El”, and * means zero or more of the preceding element. So this query will return all rows where city_name starts with either “San” or “El”.

androloginOption: B
Jul 16, 2024

Regex patterns: ^ - used to capture the start of the text/string | - used as an OR operator