Question: I downloaded and installed ruby from this <https://rubyinstaller.org/downloads/> -> Ruby+Devkit 2.7.3-1 (x64) and follow the installation steps. but I got a error when I tried to install mysql2 for rails using

```
gem install mysql2

```

ruby version is 2.7.3p183

rails version is 6.1.3.2

gem version is 3.1.6

> 
> ERROR: Error installing mysql2:
> The last version of mysql2 (>= 0) to support your Ruby & RubyGems was 0.5.3. Try installing it with `gem install mysql2 -v 0.5.3`
> mysql2 requires Ruby version >= 2.2, < 2.7.dev. The current ruby version is 2.7.3.183.
> 
> 
> 

I tried gem install mysql2 -v 0.5.3 but got same error.

I installed mysql before running this command, and I also have mysql on XAMPP.
I installed MYSQL using mysql-installer-web-community-8.0.25.0

Answer: 
Just count the first time a customer is seen. One method is two levels of aggregation:

```
select store, date_trunc('month', min_created_at), count(*)
from (select store, customer_id, min(created_at) as min_created_at
      from a
      group by store, customer_id
     ) c
group by 1, 2;

```

Note: `monthname()` is not appropriate for defining a month, because it does not take the year into account. If you really do want to ignore the year, you can use `monthname()` but that seems unusual.
Hope this sql statement helps!

select store, monthname(created\_at), count(distinct customer\_id)
from a
where monthname(created\_at)=MONTHNAME(current\_date())
group by 1,2;