SELECT installed_on, COUNT(DATEDIFF(login_on, installed_on) = 1 or NULL) / COUNT(DATEDIFF(login_on, installed_on) = 0 or NULL) AS day1, COUNT(DATEDIFF(login_on, installed_on) = 2 or NULL) / COUNT(DATEDIFF(login_on, installed_on) = 0 or NULL) AS day2, COUNT(DATEDIFF(login_on, installed_on) = 3 or NULL) / COUNT(DATEDIFF(login_on, installed_on) = 0 or NULL) AS day3, COUNT(DATEDIFF(login_on, installed