简体   繁体   中英

MySQL Workbench: How do I select specific rows with a certain date? How do I exclude dates?

I have been tasked to find the number of users who were active but stopped using an app since Feb.

How do I get all the users who have shown no activity since February of this year?

I know that I have to join two tables in my database, the users table and game_users

This is the structure for the users table

id | first_name | last_name 
11 |Kyle | John 

Game_users

game_id | user_id | established_at | deleted_at | host | join
123456 | 46768 | 2020-09-23 14:23:56 | 2020-09-27 22:49:04 | 1 | 0

(host here refers to people who hosted a game and join refers to people who just joined)

I need the users that only have activity up until February with no activity afterward, how do I exclude these dates?

I figured that I can use a subquery, but I am confused as to how?

Thank you :)

You can use aggregation and compare dates. I think that is something like this:

select user_id
from game_users
group by user_id
having max(established_at) < '2020-02-01';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM