Question: Coding in postgreSQL I need to use a FUNCTION to transform data. The data I want to transform is the first_name and last_name fields

Coding in postgreSQL 

 

I need to use a FUNCTION to transform data. The data I want to transform is the first_name and last_name fields from the "staff" table into a "full_name" field so the end table uses the full name of the employee instead of the first and last separately. The names need to be separated by a space. The full_name field will be used in my table. Currently I have this code for my table, the function will be used in place of the s.first_name and s.last_name.

 

-- Summary Table DROP TABLE IF EXISTS employee_rev; CREATE TABLE employee_rev (
 

-- Summary Table DROP TABLE IF EXISTS employee_rev; CREATE TABLE employee_rev ( staff_id int, first_name VARCHAR(255), last_name VARCHAR(255), employee_sales money ) ; INSERT INTO employee_rev (staff_id, first_name, last_name, employee_sales) SELECT s.staff_id, s.first_name, s.last_name, SUM (p. amount) as employee_rev FROM staff s INNER JOIN payment p ON s.staff_id = p.staff_id WHERE p.payment_date >= (current_date - 30000) GROUP BY s.staff_id, s.first_name, s.last_name; SELECT FROM employee_rev;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!