CREATE TABLE test (blob_col BLOB, INDEX(blob_col(10)));

0

Please login or register to vote for this query.

(click on this box to dismiss)

Skeptics

Q&A for scientific skepticism

SELECT SUM(EndOfWeekUsersCount)*100/SUM(BeginOfWeekUsersCount) AS Retention
FROM
-- количество на начало недели
(
SELECT COUNT(DISTINCT OwnerUserId) AS BeginOfWeekUsersCount FROM Posts
WHERE
CreationDate BETWEEN DATEADD(day, 0, '2008-08-01') AND 
DATEADD(day, 1, '2008-08-01')
) BeginOfWeek
-- количество на начало недели
FULL JOIN
-- количество на конец недели
(
SELECT COUNT(begin_of_week.OwnerUserId) AS EndOfWeekUsersCount
FROM
(	
SELECT DISTINCT OwnerUserId AS OwnerUserId FROM Posts
WHERE 
CreationDate BETWEEN DATEADD(day, 7, '2008-08-01') AND 
DATEADD(day, 8, '2008-08-01')
) end_of_week
INNER JOIN
(
SELECT DISTINCT OwnerUserId AS OwnerUserId FROM Posts
WHERE 
CreationDate BETWEEN DATEADD(day, 0, '2008-08-01') AND 
DATEADD(day, 1, '2008-08-01')
) begin_of_week ON end_of_week.OwnerUserId = begin_of_week.OwnerUserId
) EndOfWeek
-- количество на конец недели
ON
BeginOfWeek.BeginOfWeekUsersCount = EndOfWeek.EndOfWeekUsersCount

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results