Exam DEA-C01 All QuestionsBrowse all questions from this 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?

    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
JohnYangOption: B

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

tgvOption: B

~: 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".

androloginOption: B

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

bakarysOption: B

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”.

HunkyBunkyOption: B

B - becuase of regexp