help with oracle sql case statement using count criteria -
so far, query works using exists:
select case when exists ( select * test1 timestamp = to_char(sysdate-1, 'yyyymmdd') || '0000' ) 0 else 1 end flg dual
now, need add criteria. since data has these consistent count values of 100 example:
sql> select count(*), timestamp test1 group timestamp order 2 desc; count(*) timestamp ---------- ---------- 100 2.0111e+11 100 2.0111e+11
i need alter query have count(*) of 100
, if set flag = 0 , if not set flag =1.
i'm not sure add count criteria value of 100. can still use case this?
you try looking having
-statement:
select count(*), timestamp test1 group timestamp having count(*) = 100
basically it's same where
, aggregates.
Comments
Post a Comment