| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13  | 
						INSERT INTO c_office              (office_code,               parent_code)  SELECT DISTINCT office_code,                  CASE                    WHEN Char_length (office_code) = 4 THEN                    Substring (office_code, 1, 2)                    WHEN Char_length (office_code) = 7 THEN                    Substring (office_code, 1, 4)                    WHEN Char_length (office_code) = 10 THEN                    Substring (office_code, 1, 7)                  END  FROM   office_user  | 
					
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13  | 
						SELECT  (CASE    WHEN Substring (dsor_code, 1, 2) = 'MR' THEN    Substring (dsor_code from 3)    WHEN Substring (dsor_code, 1, 2) = 'KW' THEN    Substring (dsor_code from 3)  ELSE Substring (dsor_code from 1) END)::Integer  AS dorder,  Substring (dsor_code, 1, 2) as dtype, dsor_year, dsortype_code, dsor_code, dsor_description, unit_code, rate  FROM m_dsor WHERE dsor_year=2014 and dsortype_code=5 ORDER BY  dtype, dorder  |