Database Project 3
input limit
select tag_name, count(*) from ad_tag_map
group by tag_name
order by count(*) desc
limit 3;2) select the username and number of unique ad views of the user with the most view count on all his ads
select username, s from customer
inner join
(select creator_id, sum(unique_view_count) s from advertisement
group by creator_id
order by s desc
limit 1) A
on A.creator_id = customer.uid;input date
select distinct convo.convo_id, convo.title from
(select * from message
where message.created >= to_timestamp('12 Dec 2014', 'DD Mon YYYY')) M
inner join convo
on convo.convo_id = M.convo_id;input price
select distinct c1.username from
customer c1, advertisement a1, advertisement a2
where c1.uid = a1.creator_id and a1.price > 200 and c1.uid = a2.creator_id and a2.price > 200 and a1.ad_id != a2.ad_id;input x advertisements and y messages
(select username, email from customer
inner join
(select uid from message
group by uid
having count(*) > 2) M
on customer.uid = M.uid)
intersect
(select username, email from customer
inner join
(select creator_id from advertisement
group by creator_id
having count(*) > 1) A
on customer.uid = A.creator_id);