Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DROP VIEW IF EXISTS pigments_view;
  2.  
  3. CREATE VIEW pigments_view AS
  4.     SELECT
  5.         EXTRACT(year FROM Samples.date)                             as year,
  6.         Water_area.name                                             as waterArea,
  7.         Photosynthetic_pigments_samples.serial_number               as seqNo
  8.         Station.name                                                as station
  9.         Station_coordinates.latitude                                as latitude
  10.         Station_coordinates.longitude                               as longitude
  11.         to_char(Samples.date, 'YYYY-MM-DD')                         as date
  12.         to_char(Samples.date, 'HH24:MI')                            as time
  13.         COALESCE(Horizon_levels.name,                              
  14.                  Horizon_levels.upper_horizon_level,                
  15.                  Horizon_levels.lower_horizon_level)                as horizon
  16.         Physical_properties.max_depth                               as depth
  17.         CASE                                                        
  18.           WHEN                                                      
  19.             Physical_props_at_horizon.id_horizon = (                
  20.               SELECT id_horizon                                    
  21.               FROM Horizon_levels                                  
  22.               WHERE name like "%пов%")                              
  23.           THEN Physical_props_at_horizon.upper_temperature          
  24.         END                                                         as surfaceTemperature
  25.         CASE                                                        
  26.           WHEN                                                      
  27.             Physical_props_at_horizon.id_horizon = (                
  28.               SELECT id_horizon                                    
  29.               FROM Horizon_levels                                  
  30.               WHERE name like "%дно%")                              
  31.           THEN Physical_props_at_horizon.lower_temperature          
  32.         END                                                         as bottomTemperature
  33.         Physical_properties.transparency                            as transparency
  34.         Photosynthetic_pigments_samples.A(665K)                     as a(665k)
  35.         Photosynthetic_pigments_samples.volume_of_filtered_water    as volumeOfFilteredWater
  36.         Photosynthetic_pigments_samples.chlorophyll_a_concentration as chlA
  37.         Photosynthetic_pigments_samples.chlorophyll_b_concentration as chlB
  38.         Photosynthetic_pigments_samples.chlorophyll_c_concentration as chlC
  39.         Photosynthetic_pigments_samples.pigment_index               as pigmentIndex
  40.         Photosynthetic_pigments_samples.pheopigments                as pheopigments
  41.         Photosynthetic_pigments_samples.ratio_of_chl_a_to_chl_c     as chlAToChlC
  42.         Trophic_characterization_of_water.name                      as trophicCharacteristics
  43.         Photosynthetic_pigments_samples.comment                     as notes
  44.  
  45.     FROM Photosynthetic_pigments_samples
  46.     INNER JOIN Samples ON
  47.         Samples.id_sample = Photosynthetic_pigments_samples.id_sample
  48.     INNER JOIN Station ON
  49.         Station.id_station = Samples.id_station
  50.     INNER JOIN Water_area ON
  51.         Water_area.id_water_area = Station.id_water_area
  52.     INNER JOIN Station_coordinates ON
  53.         Station_coordinates.id_sample = Station.id_station
  54.     INNER JOIN Horizon_levels ON
  55.         Horizon_levels.id_horizon = Photosynthetic_pigments_samples.id_horizon
  56.     INNER JOIN Physical_properties ON
  57.         Physical_properties.id_sample = Samples.id_sample
  58.     INNER JOIN Physical_props_at_horizon ON
  59.         Physical_props_at_horizon.id_physical_props =
  60.         Physical_properties.id_physical_props
  61.     INNER JOIN Trophic_characterization_of_water ON
  62.         Trophic_characterization_of_water.id_trophic_characterization =
  63.         Photosynthetic_pigments_samples.id_trophic_characterization
  64.        
  65.    
  66.     WHERE
  67.         /*    for latitude and longitude      */
  68.         Station_coordinates.date <= Samples.date;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement