创建标志列

时间:2018-04-19 13:54:41

标签: sql oracle

我想请你帮忙。我想创建一个标志列,它将标记特定的合同编号为1,其中“CLOSED”列在某些行中为空。

我试过

case when CLOSED is null then 1 else 0 end as flag
group by CONTRACT_NUMBER 

但它不起作用。感谢您的回复

example picture

1 个答案:

答案 0 :(得分:2)

我认为您需要解析max()

<强> demo

select t.*, 
       max(case when closed is null 
                then 1 
                else 0 
           end) over (partition by contract_number) as flag
  from t