I got awesome response to the previous MySQL Challenge. Awesome means, I got 6 responses, out of which 5 are correct (working) solutions and 2 are optimized solutions. You must be thinking, just 6 responses, but I am saying awesome. Yes, in my opinion quality is what matters, not quantity. I will explain the solution to that MySQL challenge in few more days. Before that, I am back with another small problem. This problem deals with numbers and simple mathematical calculations like addition.
While we were working at Indibits, on a project, we had a small requirement. We had to calculate all sign ups so far in this week. And our week starts from Saturday. I wanted to do it all in one shot. A single, short and optimized MySQL query which will return the count of all valid sign ups happened at or after 12 AM on last Saturday. And if today is Saturday, then we consider today as the date. But the problem was, how to get date of last Saturday? In PHP, it is almost easy. But in MySQL it was looking bit difficult. But when I started finding the solution, then I realized, it’s more difficult than I estimated. But I applied my logic and found a good and optimized solution in just 12 minutes.