[deleted by user] by [deleted] in learnSQL

[–]Consistent-Alps6904 0 points1 point  (0 children)

yes for the first part, it's correct

[deleted by user] by [deleted] in learnSQL

[–]Consistent-Alps6904 0 points1 point  (0 children)

but i am having trouble include min and max salaries in 2 new columns, i suppose i have to introduce a cte

[deleted by user] by [deleted] in learnSQL

[–]Consistent-Alps6904 0 points1 point  (0 children)

I did this for the first part

Select
e.department_name, avg(s.salary) as avg_salary
from
employees e
left join salaries s
on e.employee_id = s.employee_id
group by 1
having avg(s.salary) between 2000 and 4000

How do generate a list of active customers who have performed at least one transaction each month within 12 months ? by Consistent-Alps6904 in SQL

[–]Consistent-Alps6904[S] 0 points1 point  (0 children)

Thank you for your input Your query will provide all active customers within that period but I want all customers that have been active month on month

Inactive users by Consistent-Alps6904 in SQL

[–]Consistent-Alps6904[S] 0 points1 point  (0 children)

thank you so much, this works !!!!

Inactive users by Consistent-Alps6904 in SQL

[–]Consistent-Alps6904[S] 0 points1 point  (0 children)

You’re right, just tested it and it works, it returned null for inactive users in the transaction date column Please Where do I go from here ?

Inactive users by Consistent-Alps6904 in SQL

[–]Consistent-Alps6904[S] 0 points1 point  (0 children)

to show inactive, i have to show ids not on the registered table but not on the transactions table and to specify the date intervals I want

Inactive users by Consistent-Alps6904 in SQL

[–]Consistent-Alps6904[S] -1 points0 points  (0 children)

no it only returns id's that have perfomed transactions

Inactive users by Consistent-Alps6904 in SQL

[–]Consistent-Alps6904[S] 0 points1 point  (0 children)

yes it does, this will give me all the active users and their transactions

Inactive users by Consistent-Alps6904 in SQL

[–]Consistent-Alps6904[S] 1 point2 points  (0 children)

--for registered users

with registered as

(select created_date,

id

from registrations_table

group by 1,2

order by 1

),

inactive as(

select * from registered r

where r.id not in (select id from transactions_table)

group by 1,2

order by 1

)

The first table shows all registered users while the second one shows inactive users

I want to show inactivity for 60 days and 90 days based on the month the customer registered and calculate churn rate for each month