Knowee
Questions
Features
Study Tools

SELECT date(create_time) date, count(distinct device_id) FROM event_logs where event_id='home_page_view' GROUP BY date order by date desc union SELECT date(create_time) date, count(device_id) FROM event_logs where event_id='home_page_view' GROUP BY date order by date desc

Question

SELECT date(create_time) date, count(distinct device_id) FROM event_logs where event_id='home_page_view' GROUP BY date order by date desc union SELECT date(create_time) date, count(device_id) FROM event_logs where event_id='home_page_view' GROUP BY date order by date desc

🧐 Not the exact question you are looking for?Go ask a question

Solution

This SQL query is doing the following:

  1. It is selecting the date of creation and the count of distinct device IDs from the event_logs table where the event ID is 'home_page_view'. This is done for each unique date.

  2. The results are then grouped by the date and ordered in descending order.

  3. The UNION operator is used to combine the result-set of the above query with the result-set of the second query.

  4. The second query is similar to the first one, but it counts all device IDs (not just distinct ones) from the event_logs table where the event ID is 'home_page_view'. This is also done for each unique date.

  5. The results of the second query are also grouped by the date and ordered in descending order.

  6. The UNION operator removes duplicate rows between the two select statements.

Please note that the two queries must have the same number of columns and the corresponding columns must have compatible data types.

This problem has been solved

Similar Questions

SELECT DISTINCT el.device_id, DATE(el.create_time) date, CASE WHEN el.platform IN ('') THEN 'null' ELSE 'unknown' END AS platform_div, CASE WHEN el.event_id='home_page_view' THEN 1 ELSE 0,caseWHEN ud.country ='' THEN 'unknown' ELSE 'developing_country' END AS country_div FROM event_logs el JOIN user_devices ud ON el.device_id = ud.device_id我要如何在查询结果中加入每个device_id使用过的次数

WITH install AS ( SELECT el.user_id, el.create_time FROM event_logs el WHERE el.event_id = 'onboarding_login_view' AND el.referrer = 'plugin_installed' ) --first_usage_after_installed AS ( SELECT i.user_id, i.create_time, COALESCE(min(cr.event_time), toDateTime('1970-01-01 00:00:00')) AS first_event_time FROM install i LEFT JOIN chat_records cr ON i.user_id = cr.user_id WHERE cr.event_time > i.create_time GROUP BY i.user_id, i.create_time帮我修改代码,我要展现出用户安装后第一次使用的功能,即使没有使用也要

Table: ActivityColumn NameTypeplayer_idintdevice_idintevent_datedategames_playedint(player_id, event_date) is the primary key of this table.This table shows the activity of players of some game. Each row is a record of a player who logged in and played a number of games (possibly 0) before logging out on some day using some device.Write a SQL query that reports the device that is first logged in for each player.The query result format is in the following example:Activity table:player_iddevice_idevent_idgames_played122016-03-015122016-05-026232017-06-251312016-03-020342018-07-035Result table:player_iddevice_id122331Optionsselect player_id, device_idfrom Activitywhere (player_id, event_date) in (select player_id, min(event_date)group by player_id);select player_id, device_idfrom Activity (player_id, event_date) in ( select player_id, min(event_date) from Activity group by player_id);select player_id, device_idfrom Activitywhere (player_id, event_date) in ( select player_id, min(event_date) from Activity group by player_id);select device_idfrom Activity where (player_id, event_date) in (select player_id, min(event_date)from Activity group by player_id);

Given a table bugs(id, token, title, category, device, reported_at, created_at, updated_at), find how many bugs were created on 2019-03-01 or later. Your query should output a table with the following columns (count).

Game Play Analysis IITable: ActivityColumn NameTypeplayer_idintdevice_idintevent_datedategames_playedint(player_id, event_date) is the primary key of this table.This table shows the activity of players of some game. Each row is a record of a player who logged in and played a number of games (possibly 0) before logging out on some day using some device.Write a SQL query that reports the device that is first logged in for each player.The query result format is in the following example:Activity table:player_iddevice_idevent_idgames_played122016-03-015122016-05-026232017-06-251312016-03-020342018-07-035Result table:player_iddevice_id122331Optionsselect device_idfrom Activity where (player_id, event_date) in (select player_id, min(event_date)from Activity group by player_id);select player_id, device_idfrom Activitywhere (player_id, event_date) in (select player_id, min(event_date)group by player_id);select player_id, device_idfrom Activity (player_id, event_date) in ( select player_id, min(event_date) from Activity group by player_id);select player_id, device_idfrom Activitywhere (player_id, event_date) in ( select player_id, min(event_date) from Activity group by player_id);Finish

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.