 (
   select
     nextval('public.gtu_properties_id_seq') as id,
-    flat.id as flat_id,
+    s.id as specimen_id,
     (CASE WHEN date_to_mask = 0 THEN NULL::timestamp ELSE date_to END - CASE WHEN date_from_mask = 0 THEN NULL::timestamp ELSE date_from END) as duration,
-    min(v.property_value) as lowervalue,
-    case when max(property_value) = min(property_value) then null::text else max(property_value) end as uppervalue,
-    property_method as method ,
+    lower_value,
+    upper_value,
+    method as method ,
     property_unit as unit,
     CASE WHEN date_from_mask = 0 THEN NULL::timestamp ELSE date_from END as date_from,
     CASE WHEN date_to_mask = 0 THEN NULL::timestamp ELSE date_to END as date_to,
-    trim(property_type  || ' / ' || lower(property_sub_type), ' / ') as parameter,
     gtu.id as gtu_ref,
-    property_qualifier as qualifier,
-    avg(v.property_accuracy_unified) as accuracy
-  FROM 
-    darwin2.darwin_flat as flat
-    INNER JOIN darwin2.gtu ON flat.gtu_ref = gtu.id
-    INNER JOIN darwin2.catalogue_properties c ON referenced_relation = 'gtu' AND record_id = gtu.id
-    INNER JOIN darwin2.properties_values v ON property_ref = c.id 
-  WHERE 
-    property_type != 'geo position' and property_sub_type not in ('height', 'altitude', 'depth') and station_visible = true
-
-  GROUP BY 
-    flat.id,
+    applies_to,
+    property_type
+  FROM
+    darwin2.specimens as s
+    INNER JOIN darwin2.gtu ON s.gtu_ref = gtu.id
+    INNER JOIN darwin2.properties c ON referenced_relation = 'gtu' AND record_id = gtu.id
+  WHERE
+    /*property_type != 'geo position' and applies_to not in ('height', 'altitude', 'depth') and*/ station_visible = true
+
+  GROUP BY
+    s.id,
     gtu.id ,
-    c.id,
+    c.id
+    /*,
     (CASE WHEN date_to_mask = 0 THEN NULL::timestamp ELSE date_to END - CASE WHEN date_from_mask = 0 THEN NULL::timestamp ELSE date_from END),
-    property_method, 
+    property_method,
     property_unit,
     CASE WHEN date_from_mask = 0 THEN NULL::timestamp ELSE date_from END ,
     CASE WHEN date_to_mask = 0 THEN NULL::timestamp ELSE date_to END,
     trim(property_type  || ' / ' || lower(property_sub_type), ' / '),
     gtu.id ,
-    property_qualifier
+    property_qualifier*/
 );
 
 ALTER TABLE public.gtu_properties ADD CONSTRAINT pk_gtu_properties PRIMARY KEY (id);
 
-CREATE INDEX idx_gtu_properties_flat_id ON public.gtu_properties (flat_id);
+CREATE INDEX idx_gtu_properties_specimen_id ON public.gtu_properties (specimen_id);
 CREATE INDEX idx_gtu_properties_gtu_ref ON public.gtu_properties (gtu_ref);
 
 


CREATE TABLE public.gtu_place as
(
  select 
  nextval('public.gtu_place_id_seq') as id,
  f.id as flat_id,
  tag as place
  
  FROM  darwin2.darwin_flat f
  
  inner join darwin2.tags ON f.gtu_ref = tags.gtu_ref

  WHERE sub_group_type != 'country' and station_visible = true
);

ALTER TABLE public.gtu_place ADD CONSTRAINT pk_gtu_place_id PRIMARY KEY (id);
CREATE INDEX idx_gtu_place_flat_id ON public.gtu_place (flat_id);
CREATE INDEX idx_gtu_place_place ON public.gtu_place (place);



                     on p.id = pr.person_1_ref
                   )
                 on c.people_ref = p.id and p.is_physical = true
               )
    on s.id = c.record_id  AND c.referenced_relation = 'specimens' AND c.people_type = 'collector'
  union
  select
    nextval('public.collectors_abcd_id_seq') as id,
    s.id as specimen_id,
    c.order_by,
    p.formated_name as institution_formated_name,
    null::varchar as people_formated_name,
