8. String Functions Flashcards

(6 cards)

1
Q

Combine first_name and country of customer as:
<name> from <country>.

A
select first_name, country,
concat(first_name, ' from ', country) as combined_name
from customers;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Find customers whose first_name has leading or trailing whitespaces.

A
select first_name
from customers
where first_name != trim(first_name);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Remove - from a phone number.

A
select '123-456-789',
replace('123-456-789', '-', '') as new_phone
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

retrieve first 2 characters from first_name of customers table.

A
select left(first_name, 2) 
from customers;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Retrieve customers’ first names after removing the first (non-space) character.

A
select first_name,
substring(trim(first_name), 2, len(first_name)) as substr_name
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Round the number 3.516 to 2 decimal places.

A
select 3.516,
round(3.516, 2) as rounded;

3.520

How well did you know this?
1
Not at all
2
3
4
5
Perfectly