1). Generate a distribution for the #comments per story.2). Does this account for stories with 0 comments?
2. Product Sense
How would you make a list of recommended restaurant to Facebook users?What information would you need?If you have all those information, how could you build a model to get a list of top recommendations?how to test this model?what metric will you use?how could you get these data?how could you test if this product is working or not?
大概就是这样 还木有消息
这道题难道不是:
SELECT number_of_comment, COUNT(*) freq
FROM
(SELECT content_id, SUM(CASE content_type WHEN ‘‘comment’’ THEN 1 ELSE 0) number_of_comments
FROM table
WHERE content_type in (’‘post’’, ‘‘photo’’)
GROUP BY content_id)
GROUP BY number_of_comment
select cnt, count(1)
from
(select target_id, count(1) as cnt
from content_actions
where content_type = ‘‘comment’’ and traget_id not null
group by target_id) a
group by cnt
SELECT number_of_comment, COUNT(*) freq
FROM
(SELECT content_id, SUM(CASE content_type WHEN ‘‘comment’’ THEN 1 ELSE 0) number_of_comments
FROM table
WHERE content_type in (’‘post’’, ‘‘photo’’)
GROUP BY content_id)
GROUP BY number_of_comment
select
comments,
count(story) as dis_cnt
from
(select
a.content_id as story,
case when b.target_id is not NULL then b.cnts else 0 end as comments
from content_actions a
where content_type in (“post”, “photo”)
left join
(select
target_id, count(user_id) as cnts
from content_actions
where content_type = “comment”
group by 1) b
on a.content_id = b.target_id)
group by 1
select
comments,
count(distinct content_id) as stories
from
(select
content_id,
zeroifnull(comments) as comments
from (select distinct content_id
from content_actions
where content_type in (’‘photo’’, ‘‘post’’)
) a
left join (select target_id, count(user_id) as comments
from content_actions
where content_type in (’‘comments’’)
group by 1
) b
on a.content_id = b.target_id
) A
group by 1
select distinct c.content_id,
(case when t1.counts is null then 0 else t1.counts end ) as counts
from content_actions as c left join
(select target_id as content_id, count(*) as counts
from content_actions
where content_type = “comment”
group by target_id) as t1
on c.content_id = t1.content_id
where content_type != “comment”;