1. We have moved to a new forum! There may be a few things not working properly so please let us know if you find a bug. Remember to use the bbCode [ sql ] tag for SQL statements.

COUNT subselect

Discussion in 'SQL - Questions and Answers' started by martiendejong, Aug 19, 2009.

  1. martiendejong New Member

    Hi there,

    I have a query with a lot of where .. in ( .. group by having count(..) .. )
    for example:
    select userid
    from users
    where userid in
    (
    select userid
    from user_group_index
    group by userid
    having count(userid)>3
    )

    What I would like to is have the count in the select too.
    What is performance-wise the best way to do this?
    Is it possible to do this without using the join statement?

    p.s. the subqueries can be nested several times. I would like to show that counts too.

    Regards,
    Martien

Share This Page