I am trying to workout the average number of bookings made per day over a given time period.
So far I have this code:
SELECT
AVG(NumberOfBookings)
FROM
(SELECT
DATEPART(weekday, UpdatedDate) AS Days,
COUNT(*) AS NumberOfBookings
FROM
Booking
WHERE
Status = 'Confirmed'
GROUP BY
DATEPART(weekday, UpdatedDate)) AS COUNTS
When I run it I just get 1 result which is the average of all bookings per day rather than an individual average for each day of the week.
I also tried running this:
SELECT Days,
AVG(NumberOfBookings)
FROM
(SELECT
DATEPART(weekday,UpdatedDate) AS Days,
COUNT(*) AS NumberOfBookings
FROM
Booking
WHERE
Status = 'Confirmed'
GROUP BY
DATEPART(weekday,UpdatedDate)) AS COUNTS
GROUP BY
Days
But this just gives me the total from each day rather than the average.
The Bookings table includes these columns: BookingID, BookingDate, CustomerID, UpdatedDate, Status