ExamGecko
Question list
Search
Search

List of questions

Search

Related questions











Question 117 - DEA-C01 discussion

Report
Export

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|EI)';

Answers
A.

Select * from Sales where city_name - '$(San|EI)';

B.

Select * from Sales where city_name -, ^(San|EI) *';

Answers
B.

Select * from Sales where city_name -, ^(San|EI) *';

C.

Select * from Sales where city_name - '$(San&EI)';

Answers
C.

Select * from Sales where city_name - '$(San&EI)';

D.

Select * from Sales where city_name -, ^(San&EI)';

Answers
D.

Select * from Sales where city_name -, ^(San&EI)';

Suggested answer: B

Explanation:

To query the Sales table in Amazon Redshift for city names that start with 'San' or 'El,' the appropriate query uses a regular expression (regex) pattern to match city names that begin with those prefixes.

Option B: Select * from Sales where city_name ~ '^(San|El)'; In Amazon Redshift, the ~ operator is used to perform pattern matching using regular expressions. The ^(San|El) pattern matches city names that start with 'San' or 'El.' This is the correct SQL syntax for this use case.

Other options (A, C, D) contain incorrect syntax or incorrect use of special characters, making them invalid queries.

Amazon Redshift Pattern Matching Documentation

asked 29/10/2024
Azfar khan
40 questions
User
Your answer:
0 comments
Sorted by

Leave a comment first