Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Needing help with my SQL ( for Postgres ) . Errors at end. Tasks: 1 . What is the full name, full address, title, and
Needing help with my SQL for Postgres Errors at end. Tasks:
What is the full name, full address, title, and phone number for all employees currently living in a US state that shares a border with the Pacific Ocean?
Give the same information for all employees not in the USA but are older than years of age.
Which employees last name, first name without repeats have placed orders delivered to Norway?
What is the title and name of any employee that has sold at least two of either "Vegiespread" or "Sir Rodneys Marmalade"?
hat are the Employee IDs for all employees who have sold more than products?
List the last name of all employees that live on the same city as their managers.
List the product names of all products that were bought OR sold by people who live in London use a UNION
What is the average price of products for each category? Output just the average price as "averageprice" and the category ID
Script:
Question : Full name, full address, title, and phone number for employees living in a US state bordering the Pacific Ocean
SELECT CONCATfirstname, lastname AS fullname,
CONCATaddress city, region, postalcode AS fulladdress,
title,
phonenumber
WHERE country 'USA'
AND region IN Washington 'Oregon', 'California', 'Alaska', 'Hawaii';
Question : Full name, full address, title, and phone number for employees not in the USA but older than
SELECT CONCATfirstname, lastname AS fullname,
CONCATaddress city, region, postalcode AS fulladdress,
title,
phonenumber
FROM employees
WHERE country 'USA'
AND age ;
Question : Employees last name, first name without repeats who have placed orders delivered to Norway
SELECT DISTINCT lastname, firstname
FROM employees e
JOIN orders o ON eemployeeid oemployeeid
JOIN customers c ON ocustomerid ccustomerid
WHERE ccountry 'Norway';
Question : Title and name of employees who have sold at least two of "Vegiespread" or "Sir Rodneys Marmalade"
SELECT title, CONCATfirstname, lastname AS employeename
FROM employees e
JOIN orders o ON eemployeeid oemployeeid
JOIN orderdetails od ON oorderid odorderid
JOIN products p ON odproductid pproductid
WHERE pproductname IN Vegiespread', 'Sir Rodneys Marmalade'
GROUP BY eemployeeid
HAVING COUNT;
Question : Employee IDs for employees who have sold more than products
SELECT employeeid
FROM orders
GROUP BY employeeid
HAVING SUMquantity;
Question : Last name of employees living in the same city as their managers
SELECT elastname
FROM employees e
JOIN employees m ON ereportsto memployeeid
WHERE ecity mcity;
Question : Product names bought or sold by people who live in London using UNION
SELECT pproductname
FROM products p
JOIN orderdetails od ON pproductid odproductid
JOIN orders o ON odorderid oorderid
JOIN customers c ON ocustomerid ccustomerid
WHERE ccity 'London'
UNION
SELECT pproductname
FROM products p
JOIN customerdemographics cd ON pproductid cdproductid
JOIN customers c ON cdcustomerid ccustomerid
WHERE ccity 'London';
Question : Average price of products for each category
SELECT AVGunitprice AS averageprice, categoryid
FROM products
GROUP BY categoryid;
Errors:
Unable to resolve column 'phonenumber' :
Unable to resolve column 'phonenumber' :
Unable to resolve column 'age' :
Unable to resolve column 'quantity' :
Unable to resolve column 'productid :
Unable to resolve column 'customerid :
Thanks in advance!
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