-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathother problems.sql
More file actions
39 lines (33 loc) · 992 Bytes
/
other problems.sql
File metadata and controls
39 lines (33 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Q1.
-------------------
SELECT date, COUNT(DISTINCT ssession_id)/COUNT(user_id) AS avg_number_session_per_user
FROM A
GROUP BY date
Q2. ?
-------------------
SELECT time_spent, COUNT(DISTINCT user_id) AS number_of_user
FROM A JOIN B
ON A.session_id = b.session_id
GROUP BY time_spent
Q597.
-------------------
SELECT COALESCE(ROUND(COUNT(DISTINCT requester_id, accepter_id)/
COUNT(DISTINCT sender_id, send_to_id), 2), 0) AS accept_rate
FROM friend_request, request_accepted
Q602.
------------------
SELECT id1 AS id, COUNT() AS num_friendss
FROM (SELECT requester_id AS id1, accepter_id AS id id2 FROM request_accepted
UNION
SELECT accepter_id AS id1, requester_id AS id id2 FROM request_accepted) tmp
GROUP BY id1
ORDER BY COUNT()
LIMIT 1
Q578.
------------------
SELECT tmp.question_id AS survey_log
FROM (SELECT question_id, CASE WHEN action = 'answer' THEN 1 ELSE 0 END AS answer
FROM q_table) tmp
GROUP BY tmp.question_id
ORDER BY SUM(tmp.answer) DESC
LIMIT 1