Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

need query.sql. these are the fields: trans_id : a SERIAL (this is the order id mentioned below) cust_id : a string that uniquely identifies the

need query.sql.

these are the fields:

trans_id : a SERIAL (this is the "order id" mentioned below)

cust_id : a string that uniquely identifies the customer

employee: a string for the name of the employee who is managing this transaction (sorry I managed to miss this field in the initial writeup)

prod_id : a string that uniquely identifies the product sold to the customer

supplier_id : a string that identifies where we get the product from

quantity : an integer for how much of the product was sold

unit_price :the price for one unit of the product

trans_date: date on which the transaction was completed

image text in transcribed

3. Create a script "query.sql" that includes semicolon-separated queries to do the following (terminate each query with a semicolon so the grader can run the whole script at once) : 1. List distinct suppliers used by company 1. Make sure there is more than one record for at least one supplier 2. List order ID, customers helped by Tom and the dates on which the orders he helped with were completed. 1. There should be at least two orders for Tom to help with 3. List suppliers, product ID, quantity, price, transaction date, with a generated total cost column, ordered most recent to oldest 1. Orders should take place on more than one date 2. The cost is just the product of quantity and price 3. Give this column an alias (nickname) and use the alias in the ORDER BY clause 4. The "ORDER" keyword is why we cannot just call the table Order 4. List order id, customer, employee, supplier, trans_date that completed in December 2022 1. Here, the EXTRACT function described in PostgreSQL: Documentation: 15: 9.9. Date/Time Functions and Operators answer 2. Try EXTRACT in the SELECT clause first to see how it behaves

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

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

1st Edition

1597496251, 978-1597496254

More Books

Students also viewed these Databases questions

Question

Identify the cause of a performance problem. page 363

Answered: 1 week ago