Jeannie D
Jeannie D

Reputation: 1

SQL - getting details from a group by clause

I can use the following query...

select ProcessTime, count(psid) as Cases
from cov.pslog 
group by ProcessTime 
having count(ProcessTime) > 1
order by ProcessTime asc

to generate results like this...

13:40   10
13:55   2
16:07   11
16:08   6

but what I really want is to see all the individual psid's for instances where there is more than 1 per ProcessTime value. i.e. show me the 10 psids that were processed at 13:40.

I have tried so many variations, but this is as close as I can get.

Upvotes: 0

Views: 26

Answers (1)

MiguelKVidal
MiguelKVidal

Reputation: 1538

Please try the following query:

SELECT * FROM pslog WHERE processtime in (
    select ProcessTime
    from pslog
    group by ProcessTime
    having count(ProcessTime) > 1
    order by ProcessTime asc
)

http://sqlfiddle.com/#!9/0018a2/1

Upvotes: 1

Related Questions