Answered step by step
Verified Expert Solution
Link Copied!

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.

 

image.png
 

-- 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Entrepreneurship

Authors: Andrew Zacharakis, William D Bygrave

5th Edition

1119563097, 9781119563099

More Books

Students also viewed these Databases questions

Question

Does it give you information you can act on to improve your impact?

Answered: 1 week ago

Question

What is the consumer-purchase-decision process? AppendixLO1

Answered: 1 week ago