Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 ( 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started