sql - counting groups which contain an element with a certain attribute -


i have table containing 3 values

create table x ( start      integer not null, end        integer not null, random     integer not null); 

i want count amount of groups (group start,end) contain @ least 1 element random > 42 bigger 1 element. far know having can used aggregate functions.

my current attempt:

select count(*) ( select count(*) routes  group start,end  having random > 42  , count(*) > 1); 

results in

no such column: random

what efficient way solve problem?

select count(*)  (select sum(case when random > 42 1 else 0 end) cnt         routes          group start,end        having count(*) > 1) t cnt > 1 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -