dark-nebula-portfolio / analysis.html
coder-000's picture
Customers and Products Analysis Using SQL
7124abf verified
Raw History Blame Contribute Delete
2.77 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>SQL Analysis</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
.sql-container {
background-color: #f8f9fa;
border-radius: 5px;
padding: 20px;
margin-bottom: 20px;
}
.result-container {
background-color: #e9ecef;
border-radius: 5px;
padding: 15px;
margin-top: 10px;
}
pre {
background-color: #212529;
color: #f8f9fa;
padding: 10px;
border-radius: 5px;
}
</style>
</head>
<body>
<div class="container py-4">
<h1 class="mb-4">Customers and Products Analysis</h1>
<div class="sql-container">
<h3>Top Customers by Revenue</h3>
<pre>
SELECT c.customer_name, SUM(oi.quantity * oi.unit_price) AS total_revenue
FROM customers c
JOIN orders o ON c.customer_id = o.customer_id
JOIN order_items oi ON o.order_id = oi.order_id
GROUP BY c.customer_name
ORDER BY total_revenue DESC
LIMIT 10;
</pre>
<div class="result-container">
<p>Results will appear here when run...</p>
</div>
</div>
<div class="sql-container">
<h3>Product Performance Analysis</h3>
<pre>
SELECT p.product_name,
SUM(oi.quantity) AS total_units_sold,
SUM(oi.quantity * oi.unit_price) AS total_revenue,
AVG(oi.unit_price) AS avg_price
FROM products p
JOIN order_items oi ON p.product_id = oi.product_id
GROUP BY p.product_name
ORDER BY total_revenue DESC;
</pre>
<div class="result-container">
<p>Results will appear here when run...</p>
</div>
</div>
<div class="sql-container">
<h3>Customer Purchase Frequency</h3>
<pre>
SELECT c.customer_name,
COUNT(DISTINCT o.order_date) AS purchase_days,
COUNT(o.order_id) AS total_orders,
COUNT(o.order_id) / COUNT(DISTINCT o.order_date) AS orders_per_day
FROM customers c
JOIN orders o ON c.customer_id = o.customer_id
GROUP BY c.customer_name
ORDER BY orders_per_day DESC;
</pre>
<div class="result-container">
<p>Results will appear here when run...</p>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>