SQL Group result with specific criteria -


i need select , group id's of conditionid values 1

   id     conditionid     2       0     2       1     2       0     3       0     3       0     4       1     4       1 

the result should be:

id     conditionid              4       1 

how can this?

this can done checking if row count per id equals row count of conditionid = 1 per id, in table.

select id tablename group id having count(*) = count(case when conditionid = 1 1 end) 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -