oracle query to compare all the rows having same id in a table

前端 未结 1 591
-上瘾入骨i
-上瘾入骨i 2021-01-26 17:22

Need an sql query which results those records whose status is complete for a same id. For example, mytable is the table name which has various records. We need to

相关标签:
1条回答
  • 2021-01-26 17:51

    This will find the ids where all its rows have a status of complete:

    SELECT id
    FROM   mytable
    GROUP BY id
    HAVING COUNT(*) = COUNT( CASE status WHEN 'complete' THEN 1 END )
    
    0 讨论(0)
提交回复
热议问题