How do I return my records grouped by NULL and NOT NULL?

前端 未结 14 939
说谎
说谎 2021-01-30 16:24

I have a table that has a processed_timestamp column -- if a record has been processed then that field contains the datetime it was processed, otherwise it is null.

14条回答
  •  不思量自难忘°
    2021-01-30 16:34

    If it's oracle then you can do:

    select decode(field,NULL,'NULL','NOT NULL'), count(*)
    from table
    group by decode(field,NULL,'NULL','NOT NULL');
    

    I'm sure that other DBs allow for similar trick.

提交回复
热议问题