0% found this document useful (0 votes)
14 views

Assignment SQL 3

The document contains a series of SQL queries designed to extract specific data from a database. Each question targets different aspects of the products, orders, and customers, such as filtering by price, calculating averages, and joining tables based on certain conditions. The queries focus on retrieving information about product pricing, order details, and customer data from specified locations.

Uploaded by

superfilo98i
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Assignment SQL 3

The document contains a series of SQL queries designed to extract specific data from a database. Each question targets different aspects of the products, orders, and customers, such as filtering by price, calculating averages, and joining tables based on certain conditions. The queries focus on retrieving information about product pricing, order details, and customer data from specified locations.

Uploaded by

superfilo98i
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment 3

QUESTION 1

select productid, productname, unitprice from products


where unitprice > 50
order by unitprice desc
limit 5

QUESTION 2

select categoryid, round(avg(unitprice)) as avg_price from products


group by categoryid
having avg(unitprice) > 20
order by avg_price desc

QUESTION 3

select orderid, sum(unitprice*quantity*(1-discount)) total_order_amt from orderdetails o


where discount > 0
group by orderid
having count(orderid) > 3
order by total_order_amt;
QUESTION 4

select orderid, c.companyname, orderdate from orders o


join customers c
on o.customerid=c.customerid
where shipcountry = 'Germany'

QUESTION 5

select productname, companyname from products p


join suppliers s
on p.supplierid=s.supplierid
where country='USA'
QUESTION 6

select productname, categoryname from products p


join categories c
on p.categoryid=c.categoryid
where categoryname in ('Beverages', 'Condiments')

QUESTION 7

select orderid, companyname, freight from orders o


join customers c
on o.customerid=c.customerid
where freight > 100

You might also like