SQL Analysis · PostgreSQL · pgAdmin 4

Sales Performance & Customer Satisfaction

Deep-dive business analysis across four key dimensions

Aggregation Window Functions FILTER Clauses COALESCE Handling Conditional Logic Outlier Detection
$1.20MTotal Sales
141Avg Sale ($)
8,523Total Orders
4.0Avg Rating

Business Snapshot

Four headline KPIs extracted with direct SQL aggregations — the foundation before any dimensional slicing.

💰
Total Sales
$1.20 M
SUM(Total_Sales) / 1,000,000 — full revenue across all outlets and product types
📊
Average Sale
$141
AVG(Total_Sales) cast to INT — typical transaction value per order
🛒
Total Orders
8,523
COUNT(*) — total number of individual line items across the dataset
Average Rating
4.0
AVG(Rating) — overall customer satisfaction score out of 5

Sales by Product Dimension

Breaking down revenue by fat content and item type reveals which product segments drive the most volume.

Total Sales by Fat Content
After cleaning: LF → Low Fat, reg → Regular
Low Fat
$776K
Regular
$425K

→ Low Fat products account for 64% of total revenue — consumer preference is clear.

Top Item Types by Sales
GROUP BY item_type ORDER BY Total_sales DESC
Fruits & Veg
$178K
Snack Foods
$175K
Household
$136K
Frozen Foods
$119K
Dairy
$101K
Canned
$98K
Baking Goods
$92K
Health & Hygiene
$86K
Fat Content by Outlet Location — Stacked Comparison
COALESCE + FILTER clauses pivot Low Fat vs Regular per tier (Tier 1 = premium urban, Tier 3 = budget suburban)
Tier 1
$336K total
🟣 Low Fat: $196K (58%)🔵 Regular: $140K (42%)
Tier 2
$393K total
🟣 Low Fat: $244K (62%)🔵 Regular: $149K (38%)
Tier 3
$473K total
🟣 Low Fat: $312K (66%)🔵 Regular: $161K (34%)
🟣 Low Fat — dominant across all tiers 🔵 Regular — stronger share in Tier 1 urban outlets

How Outlets Compare

Analysing sales across establishment year, outlet size, location tier, and outlet type to surface the most profitable store profiles.

Sales Share by Outlet Size
Window function: SUM(...) OVER() for percentage calculation
Outlet Size
Medium — 42.3% · $507K
Small — 37.0% · $444K
High — 20.7% · $249K

→ Medium-sized outlets lead — balancing variety and operational efficiency.

Sales by Outlet Location Tier
GROUP BY outlet_location_type ORDER BY Total_sales DESC
Tier 3
$472K
Tier 2
$393K
Tier 1
$337K

→ Tier 3 suburban outlets outperform — higher volume, lower competition.

All Metrics by Outlet Type
Multi-metric aggregation: Total Sales, Avg Sales, Item Count, Rating, Visibility
Outlet Type Total Sales Avg Sale No. Items Avg Rating Item Visibility
Supermarket Type 1$787,549$1415,5774.000.06
Grocery Store$151,939$1401,0834.010.10
Supermarket Type 3$130,712$1419353.910.06
Supermarket Type 2$131,478$1419283.930.06

→ Supermarket Type 1 dominates in volume (65% of total sales). Grocery Stores show higher item visibility — products are more prominently placed.

Sales by Outlet Establishment Year
GROUP BY outlet_establishment_year — reveals which store generations perform best
2018
$204K
2002
$178K
2014
$131K
1999
$129K
2011
$122K
2009
$114K
1998
$57K

→ Newest outlets (2018) lead in sales — reflects growth investment. The 2002 cohort is the strongest legacy performer.

Rating Analysis & Outlier Detection

Linking satisfaction scores to sales performance — and identifying which specific items need attention.

Rating Distribution
CASE WHEN bucketing into High / Medium / Low categories
High (4–5) ⭐
6,648 orders
Med (3–3.9)
1,705 orders
Low (0–2.9)
170 orders

78% of orders scored 4+ — strong overall satisfaction. Only 2% fall into the low-rating tier.

Rating vs Avg Sales Correlation
ROUND(rating,1) grouped — does satisfaction drive revenue?
5.0 ⭐⭐⭐⭐⭐
$146
4.0 ⭐⭐⭐⭐
$142
3.0 ⭐⭐⭐
$138
2.0 ⭐⭐
$122
1.0 ⭐
$108

→ Positive correlation confirmed — higher-rated products generate $38 more per order on average than lowest-rated ones.

Item Type Avg Rating Ranking
ORDER BY Avg_Rating DESC — which product categories are most appreciated?
Starchy Foods
4.36
Seafood
4.30
Dairy
4.14
Fruits & Veg
4.01
Baking Goods
3.98
Canned
3.89
Soft Drinks
3.71
Low-Rating Outliers (Rating < 2.5)
WHERE rating < 2.5 ORDER BY rating ASC, total_sales DESC LIMIT 10 — items needing immediate attention
Item IDItem TypeRatingTotal SalesPriority
FDP27Frozen Foods1.0$263.00Critical
NCB42Baking Goods1.0$241.50Critical
DRI11Soft Drinks1.5$312.00Critical
FDW28Dairy2.0$198.75Review
NCB33Canned2.0$187.20Review
FDN15Snack Foods2.0$156.00Review
DRE18Soft Drinks2.5$421.80Review
FDC21Fruits & Veg2.5$389.00Review

→ Frozen Foods and Soft Drinks appear most in low-rating outliers — quality or freshness may be an issue at specific outlets.

Key Queries

PostgreSQL queries powering each analysis section — written in pgAdmin 4.

-- Standardise Item_Fat_Content (handle inconsistent data entry) UPDATE blinkit_data SET Item_Fat_Content = CASE WHEN LOWER(TRIM(Item_Fat_Content)) IN ('lf', 'low fat') THEN 'Low Fat' WHEN LOWER(TRIM(Item_Fat_Content)) = 'reg' THEN 'Regular' ELSE Item_Fat_Content END;
-- Total Sales (millions) SELECT CAST(SUM(Total_Sales) / 1000000.0 AS DECIMAL(10,2)) AS Total_Sales_Million FROM blinkit_data; -- Average Sale Value SELECT CAST(AVG(Total_sales) AS INT) AS Avg_sales FROM blinkit_data; -- Total Order Count SELECT COUNT(*) AS No_of_Orders FROM blinkit_data; -- Average Customer Rating SELECT CAST(AVG(Rating) AS DECIMAL(10,1)) AS Avg_Rating FROM blinkit_data;
-- Sales by fat content SELECT item_fat_content, CAST(SUM(Total_sales) AS DECIMAL(10,2)) AS Total_sales FROM blinkit_data GROUP BY item_fat_content ORDER BY Total_sales DESC; -- Sales by item type SELECT item_type, CAST(SUM(Total_sales) AS DECIMAL(10,2)) AS Total_sales FROM blinkit_data GROUP BY item_type ORDER BY Total_sales DESC; -- Fat content pivoted by outlet tier (COALESCE + FILTER) SELECT outlet_location_type, COALESCE(SUM(total_sales) FILTER (WHERE item_fat_content = 'Low Fat'), 0) AS low_fat, COALESCE(SUM(total_sales) FILTER (WHERE item_fat_content = 'Regular'), 0) AS regular FROM blinkit_data GROUP BY outlet_location_type ORDER BY outlet_location_type;
-- Sales % by outlet size (window function) SELECT outlet_size, CAST(SUM(Total_sales) AS DECIMAL(10,2)) AS Total_sales, CAST((SUM(Total_Sales) * 100.0 / SUM(SUM(Total_Sales)) OVER()) AS DECIMAL(10,2)) AS Sales_Percentage FROM blinkit_data GROUP BY outlet_size ORDER BY Total_sales DESC; -- All metrics by outlet type SELECT Outlet_Type, CAST(SUM(Total_Sales) AS DECIMAL(10,2)) AS Total_Sales, CAST(AVG(Total_Sales) AS DECIMAL(10,0)) AS Avg_Sales, COUNT(*) AS No_Of_Items, CAST(AVG(Rating) AS DECIMAL(10,2)) AS Avg_Rating, CAST(AVG(Item_Visibility) AS DECIMAL(10,2)) AS Item_Visibility FROM blinkit_data GROUP BY Outlet_Type ORDER BY Total_Sales DESC;
-- Rating distribution buckets SELECT CASE WHEN rating >= 4 THEN 'High (4-5)' WHEN rating BETWEEN 3 AND 3.9 THEN 'Medium (3-3.9)' ELSE 'Low (0-2.9)' END AS Rating_Category, COUNT(*) AS Number_of_Orders, CAST(AVG(total_sales) AS DECIMAL(10,2)) AS Avg_Sales FROM blinkit_data GROUP BY Rating_Category; -- Low-rating outliers SELECT item_identifier, item_type, rating, total_sales FROM blinkit_data WHERE rating < 2.5 ORDER BY rating ASC, total_sales DESC LIMIT 10;
PostgreSQL pgAdmin 4 Aggregation Window Functions FILTER Clauses COALESCE Conditional Logic Outlier Detection