Changes between Version 4 and Version 5 of last change fish & operation


Ignore:
Timestamp:
Dec 11, 2010 9:52:12 PM (14 years ago)
Author:
cedric
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • last change fish & operation

    v4 v5  
    4040 
    4141 
     42 
     43 
    4244-- now I still have when joining on date and station some fish pointing to more than one operation 
    4345select * from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) 
     
    5759 
    5860select * from wrbd.fish_fi where fi_op_id is null; --1346 still.... some have dates uh ? 
     61 
     62select * from wrbd.fish_fi join wrbd.operation_op op on (fi_year,fi_st_id)=(op_year,op_st_id) 
     63where fi_op_id is null and fi_date is not null; -- 645 
     64 
     65 
     66select * from wrbd.operation_op op where op_year=1974; 
     67 
     68select * from wrbd.fish_fi where fi_year=1974 and fi_st_id='st2'; 
     69--three operations missing 
     70insert into wrbd.operation_op(op_st_id,op_date,op_year) values ('st2','1974-07-18',1974); 
     71insert into wrbd.operation_op(op_st_id,op_date,op_year) values ('st2','1974-07-19',1974); 
     72insert into wrbd.operation_op(op_st_id,op_date,op_year) values ('st2','1974-07-20',1974); 
     73 
     74--exporting fishes to update_fish_1.sql 
     75select  'update wrbd.fish_fi set fi_op_id='||cast(op_id as text)||' where fi_id='||cast (fi_id as text)||';' from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) 
     76where fi_op_id is null and fi_date is not null and fi_id not in ( 
     77select fi_id from ( 
     78select count(fi_id) as count, fi_id from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) 
     79where fi_op_id is null and fi_date is not null 
     80group by fi_id) as toto where count>1); 
     81; 
     82 
     83select * from wrbd.fish_fi join wrbd.operation_op op on (fi_year,fi_st_id)=(op_year,op_st_id) 
     84where fi_op_id is null and fi_date is not null; -- 531 
     85 
     86select * from wrbd.fish_fi where fi_year=1975 and fi_st_id='st2'; 
     87select * from wrbd.operation_op op where op_year=1975; 
     88 
     89insert into wrbd.operation_op(op_st_id,op_date,op_year) values ('st2','1975-07-31',1974); 
     90insert into wrbd.operation_op(op_st_id,op_date,op_year) values ('st2','1975-08-01',1974); 
     91insert into wrbd.operation_op(op_st_id,op_date,op_year) values ('st2','1975-08-02',1974); 
     92 
     93--exporting fishes to update_fish_2.sql 
     94select  'update wrbd.fish_fi set fi_op_id='||cast(op_id as text)||' where fi_id='||cast (fi_id as text)||';' from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) 
     95where fi_op_id is null and fi_date is not null and fi_id not in ( 
     96select fi_id from ( 
     97select count(fi_id) as count, fi_id from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) 
     98where fi_op_id is null and fi_date is not null 
     99group by fi_id) as toto where count>1); 
     100; 
     101select * from wrbd.fish_fi join wrbd.operation_op op on (fi_year,fi_st_id)=(op_year,op_st_id) 
     102where fi_op_id is null and fi_date is not null; -- 474 no more st2, MI0011,MI0017, MI0018 
     103 
     104select * from wrbd.fish_fi where fi_year=1988 and fi_st_id='MI0011'; --1988-09-09 
     105 
     106select * from wrbd.operation_op op where op_year=1988 and op_st_id='MI0011'; 
     107 
     108select op_folio_no,op_st_id,op_year,op_yellow,op_p1,op_main_survey_target,op_equipment,op_nbnets,op_datasource from wrbd.operation_op op where op_date='1988-08-09' and op_st_id='MI0011'; 
     109insert into wrbd.operation_op (op_folio_no,op_st_id,op_year,op_yellow,op_p1,op_main_survey_target,op_equipment,op_nbnets,op_datasource) 
     110select op_folio_no,op_st_id,op_year,op_yellow,op_p1,op_main_survey_target,op_equipment,op_nbnets,op_datasource from wrbd.operation_op op where op_date='1988-08-09' and op_st_id='MI0011'; 
     111update wrbd.operation_op set op_date='1988-09-09' where op_id=(select max(op_id) from wrbd.operation_op); 
     112update wrbd.operation_op set op_yellow=(select count(*)  from wrbd.fish_fi where fi_date='1988-09-09' and fi_st_id='MI0011') where op_id=(select max(op_id) from wrbd.operation_op); 
     113update wrbd.operation_op set op_p1=(select count(*)  from wrbd.fish_fi where fi_date='1988-09-09' and fi_st_id='MI0011') where op_id=(select max(op_id) from wrbd.operation_op); 
     114 
     115--exporting fishes to update_fish_3.sql 
     116select  'update wrbd.fish_fi set fi_op_id='||cast(op_id as text)||' where fi_id='||cast (fi_id as text)||';' from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) 
     117where fi_op_id is null and fi_date is not null and fi_id not in ( 
     118select fi_id from ( 
     119select count(fi_id) as count, fi_id from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) 
     120where fi_op_id is null and fi_date is not null 
     121group by fi_id) as toto where count>1); 
     122 
     123select * from wrbd.fish_fi join wrbd.operation_op op on (fi_year,fi_st_id)=(op_year,op_st_id) 
     124where fi_op_id is null and fi_date is not null; -- 430  MI0017 
     125 
     126select * from wrbd.fish_fi where fi_year=1988 and fi_st_id='MI0017'; --1988-09-17 there is 09-16 fiop_id=1506 
     127select * from wrbd.fish_fi where fi_date='1988-09-17' and fi_st_id='MI0017'; 
     128update wrbd.fish_fi set fi_op_id=1506 where fi_date='1988-09-17' and fi_st_id='MI0017'; --26 lines 
     129 
     130select * from wrbd.fish_fi join wrbd.operation_op op on (fi_year,fi_st_id)=(op_year,op_st_id) 
     131where fi_op_id is null and fi_date is not null; -- 40  MI0018 2007-10-11 and MI0022 2005-06-15 
     132 
     133select * from wrbd.fish_fi where fi_year=2005 and fi_st_id='MI0022'; 
     134select * from wrbd.fish_fi where fi_date='2005-06-15' and fi_st_id='MI0022'; 
     135select distinct on (fi_op_id) fi_op_id from wrbd.fish_fi where fi_date='2005-06-14' and fi_st_id='MI0022'; 
     136update wrbd.fish_fi set fi_op_id=(select distinct on (fi_op_id) fi_op_id from wrbd.fish_fi where fi_date='2005-06-14' and fi_st_id='MI0022') 
     137 where fi_date='2005-06-15' and fi_st_id='MI0022'; -- 5 lines modified 
     138 
     139 
     140select * from wrbd.fish_fi join wrbd.operation_op op on (fi_year,fi_st_id)=(op_year,op_st_id) 
     141where fi_op_id is null and fi_date is not null; -- 40  MI0018 2007-10-11  
     142select * from wrbd.fish_fi where fi_year=2007 and fi_st_id='MI0018'; -- cette fois pas d'operation 
     143select * from wrbd.operation_op op where op_date='2007-08-14' and op_st_id='MI0018'; 
     144select op_folio_no,op_st_id,op_year,op_yellow,op_p1,op_main_survey_target,op_equipment,op_nbnets,op_datasource from wrbd.operation_op op where op_date='2007-08-14' and op_st_id='MI0018'; 
     145insert into wrbd.operation_op (op_folio_no,op_st_id,op_year,op_yellow,op_p1,op_main_survey_target,op_equipment,op_nbnets,op_datasource) 
     146select op_folio_no,op_st_id,op_year,op_yellow,op_p1,op_main_survey_target,op_equipment,op_nbnets,op_datasource from wrbd.operation_op op where op_date='2007-08-14' and op_st_id='MI0018'; 
     147update wrbd.operation_op set op_date='2007-10-11' where op_id=(select max(op_id) from wrbd.operation_op); 
     148update wrbd.operation_op set op_yellow=(select count(*)  from wrbd.fish_fi where fi_date='2007-10-11' and fi_st_id='MI0018') where op_id=(select max(op_id) from wrbd.operation_op); 
     149update wrbd.operation_op set op_p1=(select count(*)  from wrbd.fish_fi where fi_date='2007-10-11' and fi_st_id='MI0018') where op_id=(select max(op_id) from wrbd.operation_op); 
     150 
     151 
     152--exporting fishes to update_fish_4.sql 
     153select  'update wrbd.fish_fi set fi_op_id='||cast(op_id as text)||' where fi_id='||cast (fi_id as text)||';' from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) 
     154where fi_op_id is null and fi_date is not null and fi_id not in ( 
     155select fi_id from ( 
     156select count(fi_id) as count, fi_id from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) 
     157where fi_op_id is null and fi_date is not null 
     158group by fi_id) as toto where count>1); 
     159 
     160update wrbd.fish_fi set fi_op_id=2598 where fi_id=6779; 
     161update wrbd.fish_fi set fi_op_id=2598 where fi_id=6780; 
     162update wrbd.fish_fi set fi_op_id=2598 where fi_id=6781; 
     163update wrbd.fish_fi set fi_op_id=2598 where fi_id=6782; 
     164update wrbd.fish_fi set fi_op_id=2598 where fi_id=6783; 
     165update wrbd.fish_fi set fi_op_id=2598 where fi_id=6784; 
     166update wrbd.fish_fi set fi_op_id=2598 where fi_id=6785; 
     167update wrbd.fish_fi set fi_op_id=2598 where fi_id=6786; 
     168update wrbd.fish_fi set fi_op_id=2598 where fi_id=6787; 
     169update wrbd.fish_fi set fi_op_id=2598 where fi_id=6788; 
     170 
     171 
     172select * from wrbd.fish_fi join wrbd.operation_op op on (fi_year,fi_st_id)=(op_year,op_st_id) 
     173where fi_op_id is null and fi_date is not null; -- plus rien 
     174 
     175select * from wrbd.fish_fi where fi_op_id is null -- 1123 st2 et MI0037 
     176 
     177 
     178select * from wrbd.operation_op op where op_year=1973; --nothing 
     179select * from wrbd.operation_op op where op_st_id='st2'; 
     180select * from wrbd.fish_fi where fi_year=1973 and fi_st_id='st2'; 
     181insert into wrbd.operation_op (op_st_id,op_date,op_year) values('st2','1973-06-29',1973); 
     182 
     183--exporting fishes to update_fish_5.sql 
     184select  'update wrbd.fish_fi set fi_op_id='||cast(op_id as text)||' where fi_id='||cast (fi_id as text)||';' from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) 
     185where fi_op_id is null and fi_date is not null and fi_id not in ( 
     186select fi_id from ( 
     187select count(fi_id) as count, fi_id from wrbd.fish_fi join wrbd.operation_op op on (fi_date,fi_st_id)=(op_date,op_st_id) 
     188where fi_op_id is null and fi_date is not null 
     189group by fi_id) as toto where count>1); 
     190 
     191update wrbd.fish_fi set fi_op_id=2599 where fi_id=25647; 
     192update wrbd.fish_fi set fi_op_id=2599 where fi_id=25648; 
     193update wrbd.fish_fi set fi_op_id=2599 where fi_id=25649; 
     194update wrbd.fish_fi set fi_op_id=2599 where fi_id=25650; 
     195update wrbd.fish_fi set fi_op_id=2599 where fi_id=25651; 
     196update wrbd.fish_fi set fi_op_id=2599 where fi_id=25652; 
     197update wrbd.fish_fi set fi_op_id=2599 where fi_id=25653; 
     198update wrbd.fish_fi set fi_op_id=2599 where fi_id=25654; 
     199update wrbd.fish_fi set fi_op_id=2599 where fi_id=25655; 
     200update wrbd.fish_fi set fi_op_id=2599 where fi_id=25656; 
     201update wrbd.fish_fi set fi_op_id=2599 where fi_id=25657; 
     202update wrbd.fish_fi set fi_op_id=2599 where fi_id=25658; 
     203update wrbd.fish_fi set fi_op_id=2599 where fi_id=25659; 
     204update wrbd.fish_fi set fi_op_id=2599 where fi_id=25660; 
     205update wrbd.fish_fi set fi_op_id=2599 where fi_id=25661; 
     206update wrbd.fish_fi set fi_op_id=2599 where fi_id=25662; 
     207update wrbd.fish_fi set fi_op_id=2599 where fi_id=25663; 
     208update wrbd.fish_fi set fi_op_id=2599 where fi_id=25664; 
     209update wrbd.fish_fi set fi_op_id=2599 where fi_id=25665; 
     210update wrbd.fish_fi set fi_op_id=2599 where fi_id=25666; 
     211update wrbd.fish_fi set fi_op_id=2599 where fi_id=25667; 
     212update wrbd.fish_fi set fi_op_id=2599 where fi_id=25668; 
     213update wrbd.fish_fi set fi_op_id=2599 where fi_id=25669; 
     214 
     215select * from wrbd.fish_fi where fi_op_id is null -- 1123 MI0037 2008 and 2009 no dates 
     216 
     217select * from wrbd.operation_op op where op_st_id='MI0037'; --OK two operations 1961 (2008) and 1962 (2009) 
     218select * from wrbd.fish_fi join wrbd.operation_op op on (fi_year,fi_st_id)=(op_year,op_st_id) where fi_op_id is null and fi_date is null 
     219 
     220select * from wrbd.fish_fi where fi_op_id is null and fi_year=2008 and fi_st_id='MI0037' 
     221update wrbd.fish_fi set fi_op_id='1961' where fi_op_id is null and fi_year=2008 and fi_st_id='MI0037'; 
     222select * from wrbd.fish_fi where fi_op_id is null and fi_year=2009 and fi_st_id='MI0037' 
     223update wrbd.fish_fi set fi_op_id=1962 where fi_op_id is null and fi_year=2009 and fi_st_id='MI0037'; 
     224 
     225select * from wrbd.fish_fi where fi_op_id is null; --0 lines AHHHHH finished... 
    59226}}}