-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOLA SQL Project.sql
More file actions
85 lines (54 loc) · 1.87 KB
/
Copy pathOLA SQL Project.sql
File metadata and controls
85 lines (54 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Select * From Ride_Data
--1. Retrieve all successful bookings:
Select * From ride_data
Where booking_status = 'Success';
SELECT * FROM Ques1;
--2. Find the average ride distance for each vehicle type:
Select Vehicle_Type,
Round(Avg(Ride_Distance)::numeric,2) as avg_distance
From ride_data
Group By Vehicle_Type;
Select * from Ques2;
--3. Get the total number of cancelled rides by customers:
Select Count(*) From ride_data
Where Booking_Status = 'Cancelled by Customer';
Select * from Ques3;
--4. List the top 5 customers who booked the highest number of rides:
Select Customer_ID, Count(Booking_ID) as total_rides
From ride_data
Group By Customer_ID
Order By total_rides DESC Limit 5;
Select * from Ques4;
--5. Get the number of rides cancelled by drivers due to personal and car-related issues:
Select Count(*) from ride_data
Where Reason_for_cancelling_by_Driver = 'Personal & Car related issues';
Select * from Ques5;
--6. Find the maximum and minimum driver ratings for Prime Sedan bookings:
Select
Max(Driver_Ratings) As Max_Rating,
Min(Driver_Ratings) As Min_Rating
From ride_data
Where
Vehicle_Type = 'Prime Sedan'
And Driver_Ratings Is Not Null;
Select * from Ques6;
--7. Find the average customer rating per vehicle type:
Select Vehicle_Type,
Round(Avg(Customer_Rating)::numeric, 2) As Avg_Customer_Rating
From ride_data
Where Customer_Rating Is Not Null
Group By Vehicle_Type;
Select * from Ques7;
--8. Calculate the total booking value of rides completed successfully:
Select
Round(Sum(Booking_Value)::numeric, 2) As Total_Booking_Value
From
ride_data
Where
booking_status = 'Success';
Select * from Q8;
--9. List all incomplete rides along with the reason
Select Booking_Id, Incomplete_Rides_Reason
From ride_data
Where Incomplete_Rides = '1'
Select * from Q9;