Created
October 24, 2009 01:38
-
-
Save latompa/217325 to your computer and use it in GitHub Desktop.
find users with no activity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- members | |
create table members (id integer, age integer); | |
insert into members (id,age) values | |
(1,10) ,(2,20) ,(3,30) ,(4,25) ,(5,28) ,(6,37) ,(7,38) ,(8,68) ,(9,9) | |
-- posts | |
create table posts (id integer, user_id integer, title varchar(32)) | |
insert into posts (id,user_id,title) values | |
(1,1,'my blog'), | |
(2,3,'my awesome blog'), | |
(1,1,'my mediocre blog') | |
-- how many members have not posted anything | |
select count(m.id) | |
from members m | |
left outer join posts p on (m.id = p.user_id) | |
where p.user_id IS NULL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment