sql - Selecting Users signed up in past 30 days and in past 7 days in one efficient query -
I have a question that selects the number of user signups in the last 30 days:
Select as COUNT (*) from the UserCount30 user WHERE User.UserDateCreated & gt;
Then I have a question that selects the number of users signed up in the last 7 days
form of SELECT COUNT (*) In UserCount7 user from WHERE User.UserDateCreated & gt; (Strict () - interval 7 days)
Ideally, all of these are going to be part of a larger query. How do I get these two values in a skilled query, which can not be used preferably subcultures?
What to do, drag it for 30 days and calculate (*), then do a sum and XP If a statement comes back to 1 as a sum, if it is within 7 days or 0, then it is not so.
SELECT COUNT (*) AS UserCount30, SUM if ((Kurt (- (Interval) 7 days) & lt; User.UserDateCreated 1) 0 user from where the user. User account & gt; (Strict () - interval 30 days)
Comments
Post a Comment