with cte as (select u.slot,datename(m,booking_date)as months,count(booking_id)as counts,dense_rank()over (partition by slot order by count(booking_id))ranks from bookings b join users u on b.userid=u.userid group by u.slot,datename(m,booking_date)) select slot,months from cte where ranks=1