-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctions.sql
More file actions
26 lines (20 loc) · 797 Bytes
/
Functions.sql
File metadata and controls
26 lines (20 loc) · 797 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""Functions"""
-- SUBSTRING function
SELECT SUBSTRING('This is a Test String' FROM 11) test_data_extracted
-- REPLACE function
"Here we are replacing the word clothing with attire"
SELECT department,
REPLACE(department, 'Clothing', 'Attire') modified_Data,
department || ' Department' new_department
FROM departments
-- POSITION function
-- We can use the position function to help with extraction from a specific position
SELECT POSITION('@' IN email)
FROM employees
-- Using this information we can extract the domain name in email.
SELECT SUBSTRING(email, POSITION('@' IN email) +1) as domain_name
FROM employees
-- COALESCE function
-- Is used to basically replace NULL or empty cells with some data or string that we can choose
SELECT COALESCE(email, 'NONE') as email
FROM employees