General discussion

Locked

Sql Question

By maison.hughes ·
I have a table in which I need to select only the participants who have multiple rows. I tried the group by and having count(*) > 1 but I need to display each time they are in the table but only if they are in more than one. Thanks.

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by j.lupo In reply to Sql Question

Try putting your group by or having statement in a sub select. In other words

select * from table t1
where 1 < (select count(1) from table t2
where t1.key = t2.key)

It may not be efficient, but it worked in Oracle for me.

Collapse -

by farzanfar In reply to Sql Question

SELECT * FROM T1 WHERE (SELECT COUNT(*) FROM T1 AS T2 WHERE T1.Key = T2.Key) > 1

Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums