Is there a way to get multiple counts depending on multiple conditions from the same table?
eg. Count for when Days is less than 15, and count for days between 15 and 30.
Is there a way to get multiple counts depending on multiple conditions from the
Share
Yes, you can combine SUM and CASE:
So for your specific example:
If the majority of rows have
days > 30it might be worth adding aWHERE days <= 30to the end of the query as an optimization. Also be aware that BETWEEN includes both its end points.