Question: Description Problem 4 Write a query based on the vendor _ booth _ assignments table to display market _ date, vendor _ id , booth
Description
Problem
Write a query based on the vendorboothassignments table to display marketdate, vendorid boothnumber, and for each vendor on each marketdate, the boothnumber from their previous marketdate name it as previousboothnumber Sort the results by marketdate and then vendorid
query sql
F enter your SQL code below:
SELECT
vba.marketdate,
vba.vendorid
vba.boothnumber,
COALESCE prevvba.boothnumber, NA AS previousboothnumber
FROM
vendorboothassignments vba
LEFT JOIN
SELECT
vendorid
marketdate,
LAG boothnumber OVER PARTITION BY vendorid ORDER BY marketdate AS boothnumber
FROM
vendorboothassignments
ON vba.vendorid prevvba.vendorid
AND vba.marketdate prevvba. marketdate
ORDER BY
vba.marketdate,
vba.vendorid;
Description
Problem
Write a query to display marketdate, productname, and productcategoryname, as well as a field that is quantity originalprice name it as cost and a field that splits cost into tiles name it as decile with being the highest and being the lowest Only include products with a productcategoryname containing the word 'Fresh' and only during the month of September to Sort the results by marketdate and then productname.
Hint: Join the tables of productcategory, product, and vendorinventory; Use the NTILE
query.sql
enter your SQL code below:
SELECT
vimarketdate,
pproductname,
pcproductcategoryname,
vi quantity vioriginalprice AS cost
NTILE OVER ORDER BY viquantity vioriginalprice DESC AS decile
FROM
vendorinventory vi
JOIN
product ON vi productid p productid
JOIN
productcategory pC ON pproductcategoryid pcproductcategoryid
WHERE
pcproductcategoryname LIKE Fresh Filter for product categories containing 'Fresh'
AND vimarketdate
AND vimarketdate Filter for September
ORDER BY
vimarketdate,
pproductname;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
