select users.id as uid, users.displayname as name, posts....

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

select users.id as uid, users.displayname as name, posts.posttypeid as ptid, users.location as loc,
      count(case when posts.posttypeid = 1 then 1 else null end),
      count(case when posts.posttypeid = 2 then 1 else null end)
      from users, posts
      where users.id = posts.owneruserid and users.location = 'Russia'
      group by users.id, posts.posttypeid, users.location, users.displayname
      having
        count(case when posts.posttypeid = 2 then 1 else null end) > 0
        and count(case when posts.posttypeid = 1 then 1 else null end) = 0 or
        count(case when posts.posttypeid = 1 then 1 else null end) > 0
        and count(case when posts.posttypeid = 2 then 1 else null end) = 0
      order by users.id

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results