Professional Documents
Culture Documents
Challenge SQL
Challenge SQL
Challenge SQL
https://www.db-fiddle.com/f/gNRV8Tcbx9LrcxQWngLZRt/2
In that link you will see a database with two tables, this is how it works,
you write your query on the right window of the site, and you click on "play", once you have
the result you want,
you need to copy the link that was generated when running the query, and that's the first
link,
then you can erase that query and write another one, once you get the result, you copy the
link, and
so on.
cuenta reffers to the count of users new and recurrent for every month.
Ejercicio 2
Next we need to add the store to the previous table, so that we can see something like this:
For any given day, selected on a filter "and created="2021-01-13", for example, we need to
see the coupons spend amount of that day,
for new and recurrent users, then by store.
And the same for the same period of time of last month, and a Period over Period column
that shows the variation like de table in the example.
And the same but for the accumulated days of the month, like if you are selecting 2021-01-
13, you should show the accum spend of that month,
and the same for the past month, and the variation.
Ejercicio 4
As we stated before, there are clients that are activated, the month their first PO is maden,
I need a table that calls the first month they purchased, no matter what that is, the month 0,
and then, the next month and, the next, how many unique users bought again.
For example
10 sujetos compraron por primera vez(la primera vez que aparezca en la tabla) en
noviembre, en diciembre, de esos 10, sólo compraron 4 y en enero, de esos 10, sólo
compraron 5 es una cuenta, no importa quienes son, si no que compraron, se cuentan sólo
una vez aunque hayan comprado 1, 2 o 500 veces en un mes, sólo aparecerán contados
como 1.
10 people bought for the first time in november, then in december, of those 10, only 4 out of
those 10 bought again, and in january, only 5, that is a count, no matter who they are, they
are counted only once in the month, even if they made more than 1 purchase.
the resulting table should be like the one below, the month called "cohort", is the month
where they bought for the first time and is also the month 0.
Note: You gotta use the version of Mysql that is already in the fiddle (first link sent)
and you should not use create, drop, alter, sentences.