This document contains 10 SQL queries that analyze transactional and customer data for a salon services business. The queries calculate:
1) Maximum, minimum, and average prices for treatments
2) Average salaries by staff position and gender
3) Total transactions per day
4) Total transactions by customer gender
5) Most popular treatment types by total transactions
6) Revenue per day within a specified range
7) Treatment types with more than 5 transactions
8) Total treatments per transaction by staff member
9) Transactions on Thursdays by a specific staff member
10) Total price by date and customer
This document contains 10 SQL queries that analyze transactional and customer data for a salon services business. The queries calculate:
1) Maximum, minimum, and average prices for treatments
2) Average salaries by staff position and gender
3) Total transactions per day
4) Total transactions by customer gender
5) Most popular treatment types by total transactions
6) Revenue per day within a specified range
7) Treatment types with more than 5 transactions
8) Total treatments per transaction by staff member
9) Transactions on Thursdays by a specific staff member
10) Total price by date and customer
This document contains 10 SQL queries that analyze transactional and customer data for a salon services business. The queries calculate:
1) Maximum, minimum, and average prices for treatments
2) Average salaries by staff position and gender
3) Total transactions per day
4) Total transactions by customer gender
5) Most popular treatment types by total transactions
6) Revenue per day within a specified range
7) Treatment types with more than 5 transactions
8) Total treatments per transaction by staff member
9) Transactions on Thursdays by a specific staff member
10) Total price by date and customer
COUNT(hss.CustomerID) FROM HeaderSalonServices hss INNER JOIN MsCustomer ON hss.CustomerId = MsCustomer.CustomerId GROUP BY CustomerGender JASON FERNANDO / 2301875963
-- no.5
SELECT TreatmentTypeName, COUNT(dss.TreatmentID) AS [Total Transaction]
FROM MsTreatmentType mtt, DetailSalonServices dss, MsTreatment mt WHERE mtt.TreatmentTypeId = mt.TreatmentTypeId AND dss.TreatmentID = mt.TreatmentID GROUP BY TreatmentTypeName ORDER BY COUNT(dss.TreatmentID) DESC
-- no. 6
SELECT CONVERT(VARCHAR, TransactionDate, 106) AS [Date], SUM(Price) AS [Revenue per Day]
FROM HeaderSalonServices hss, MsTreatment mt, DetailSalonServices dss WHERE hss.TransactionId = dss.TransactionId AND mt.TreatmentId = dss.TreatmentId GROUP BY TransactionDate HAVING SUM(Price) BETWEEN 1000000 AND 5000000
-- no. 7
SELECT REPLACE (mtt.TreatmentTypeId, 'TT0', 'Treatment Type') AS ID,
mtt.TreatmentTypeName,[Total Treatment per Type] = CAST(COUNT(dss.TreatmentId) AS VARCHAR) + ' Treatment' FROM MsTreatmentType mtt, DetailSalonServices dss, MsTreatment mt WHERE mt.TreatmentId = dss.TreatmentId AND mt.TreatmentTypeId = mtt.TreatmentTypeId GROUP BY mtt.TreatmentTypeId, mtt.TreatmentTypeName HAVING COUNT(dss.TreatmentId) > 5
-- no. 8
SELECT LEFT(StaffName, CHARINDEX(' ', StaffName)-1) AS [StaffName], hss.TransactionID,
COUNT(dss.TransactionId) AS [Total Treatment per Transaction] FROM MsStaff ms, HeaderSalonServices hss, DetailSalonServices dss WHERE ms.StaffId = hss.StaffId AND hss.TransactionId = dss.TransactionId GROUP BY StaffName, hss.TransactionId JASON FERNANDO / 2301875963
FROM HeaderSalonServices hss, MsCustomer mc, DetailSalonServices dss, MsTreatment mt, MsStaff ms WHERE mc.CustomerId = hss.CustomerId AND hss.TransactionId = dss.TransactionId AND dss.TreatmentId = mt.TreatmentId AND hss.StaffId = ms.StaffId AND StaffName LIKE '%Ryan%' AND DATENAME(WEEKDAY, TransactionDate) = 'Thursday' ORDER BY CustomerName ASC, TransactionDate ASC
-- no. 10
SELECT TransactionDate, CustomerName, SUM(Price) AS TotalPrice
FROM HeaderSalonServices hss, MsCustomer mc, DetailSalonServices dss, MsTreatment mt WHERE hss.TransactionId = dss.TransactionId AND hss.CustomerId = mc.CustomerId AND dss.TreatmentId = mt.TreatmentId GROUP BY TransactionDate, CustomerName JASON FERNANDO / 2301875963