title: Compare previus row to set a "StatusFlag"
body: <p>I want to compare the previous row in my table on "ExtractTypeNum". So if it changed from the previous the flag should be set to "isChanged".</p>
  
  <p>I have tried to develop this with a case statement but without any success.</p>
  
  <pre><code>select * 
      (case 
          when rownum = rownum-1
              then 
                  (case when
                  extractTypeNum &lt;&gt; extractTypeNum
                      then Null
                      else 'IsChanged' end)
              when rownum = rownum -'1' then '3'
          else '4' end) as StatusFlag
  from myTable
  </code></pre>
  
  <p>This is the structure of the table and some sample data:</p>
  
  <pre><code>CREATE TABLE mytable(
     ExtractTypeNum   INTEGER  NOT NULL PRIMARY KEY 
    ,FileOrderNum     VARCHAR(11) NOT NULL
    ,PrevFileOrderNum VARCHAR(11) NOT NULL
    ,NextFileOrderNum VARCHAR(11) NOT NULL
    ,rownum1          INTEGER  NOT NULL
    ,Statusflag1      VARCHAR(9) NOT NULL
  );
  INSERT INTO mytable(ExtractTypeNum,FileOrderNum,PrevFileOrderNum,NextFileOrderNum,rownum1,Statusflag1) 
  VALUES (1,'2016-09-191',NULL,'2016-09-192',1,'IsInitial');
  INSERT INTO mytable(ExtractTypeNum,FileOrderNum,PrevFileOrderNum,NextFileOrderNum,rownum1,Statusflag1) 
  VALUES (2,'2016-09-192','2016-09-191','2016-09-201',2,NULL);
  INSERT INTO mytable(ExtractTypeNum,FileOrderNum,PrevFileOrderNum,NextFileOrderNum,rownum1,Statusflag1) 
  VALUES (1,'2016-09-201','2016-09-192','2016-09-211',3,NULL);
  INSERT INTO mytable(ExtractTypeNum,FileOrderNum,PrevFileOrderNum,NextFileOrderNum,rownum1,Statusflag1) 
  VALUES (1,'2016-09-211','2016-09-201','2016-09-222',4,NULL);
  INSERT INTO mytable(ExtractTypeNum,FileOrderNum,PrevFileOrderNum,NextFileOrderNum,rownum1,Statusflag1) 
  VALUES (2,'2016-09-222','2016-09-211',NULL,5,'IsLatest');
  
  Expected output
  +----------------+--------------+------------------+------------------+--------+-------------+
  | ExtractTypeNum | FileOrderNum | PrevFileOrderNum | NextFileOrderNum | rownum | Statusflag1 |
  +----------------+--------------+------------------+------------------+--------+-------------+
  |              1 | 2016-09-191  | NULL             | 2016-09-192      |        | IsInitial   |
  |              2 | 2016-09-192  | 2016-09-191      | 2016-09-201      |        | IsChanged   |
  |              1 | 2016-09-201  | 2016-09-192      | 2016-09-211      |        | IsChanged   |
  |              1 | 2016-09-211  | 2016-09-201      | 2016-09-222      |        | NULL        |
  |              2 | 2016-09-222  | 2016-09-211      | NULL             |        | IsLatest    |
  +----------------+--------------+------------------+------------------+--------+-------------+
  </code></pre>