I have some downtime and I’m spending it trying to learn SQL. I’ve run into a question that I’m hoping you can help me with.
Let’s say I have an incredibly simple table like this, that has a unique ID for each date (again, this is a learning exercise — otherwise I’d use an actual date and not an ID), followed by the chores I did that day:
day_id | chore
123456 | Washed the dishes
823454 | Cut the grass
123456 | Washed the dishes
123456 | Took out the trash
324234 | Washed the dishes
As you can see, it’s possible that you could do the same chore twice on the same day (in this case, I washed the dishes twice on 123456).
How could I get a count of the unique number of days that I washed the dishes (in this case, the answer should be 2)?
1 Answer