0% found this document useful (0 votes)
43 views2 pages

D33

The document contains 9 SQL queries to analyze sales and profit data from a Coffee_Chain_Sales dataset. The queries retrieve total or grouped data by product, state, sales vs target, profitability, product type, sales and profit filters, and product name filters.

Uploaded by

Anil Pradhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views2 pages

D33

The document contains 9 SQL queries to analyze sales and profit data from a Coffee_Chain_Sales dataset. The queries retrieve total or grouped data by product, state, sales vs target, profitability, product type, sales and profit filters, and product name filters.

Uploaded by

Anil Pradhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

select * from cofee

--1)Write an SQL query to retrieve the sum of sales and profit for all products in
the "Coffee_Chain_Sales" dataset.

SELECT
product,
SUM(sales) AS total_sales,
SUM(profit) AS total_profit
FROM Cofee
GROUP BY product
ORDER BY total_sales DESC;

--2)Write an SQL query to retrieve the total sales and profit for each state in the
"Coffee_Chain_Sales" dataset.

SELECT State, SUM(Sales) AS Total_Sales, SUM(Profit) AS Total_Profit


FROM Cofee
GROUP BY State;

--3)Write an SQL query to retrieve the sales and profit for all products in the
"Coffee_Chain_Sales" dataset where the profit is negative.

SELECT Product, Sales, Profit


FROM Cofee
WHERE Profit < 0;

--4)Write an SQL query to retrieve the sales and profit for all products in the
"Coffee_Chain_Sales" dataset where the sales exceed the target sales.

SELECT Product, Sales, Profit


FROM Cofee
WHERE Sales > Target_sales;

--5)Write an SQL query to retrieve the sales and profit for all products in the
"Coffee_Chain_Sales" dataset sorted by the product type in ascending order.

SELECT Product, Sales, Profit


FROM Cofee
ORDER BY Product_type ASC;

--6)Write an SQL query to retrieve the sales and profit for all products in the
"Coffee_Chain_Sales" dataset where the sales are greater than 100 and the profit is
less than 0.

SELECT Product, Sales, Profit


FROM Cofee
WHERE Sales > 100 AND Profit < 0;
--7)Write an SQL query to retrieve the sales and profit for all products in the
"Coffee_Chain_Sales" dataset where the product name contains the word "Espresso.
SELECT Product, Sales, Profit
FROM Cofee
WHERE Product LIKE '%Espresso%';
--8)Write an SQL query to retrieve the sales and profit for all products in the
"Coffee_Chain_Sales" dataset where the product name starts with the letter "L."

SELECT Product, Sales, Profit


FROM Cofee
WHERE Product LIKE 'L%';

--9)Write an SQL query to retrieve the sales and profit for all products in the
"Coffee_Chain_Sales" dataset where the product name ends with the letter "n."

SELECT Product, Sales, Profit


FROM Cofee
WHERE Product LIKE '%n';

You might also like