From 6e8c67cd3e8502ff0ab14dee114ae140181a9cc7 Mon Sep 17 00:00:00 2001 From: Dmitry Romanov Date: Sun, 3 Mar 2024 11:28:34 -0500 Subject: [PATCH] Add queries examples --- sql/examples/get_all_conditions_for_run.sql | 0 sql/examples/get_condition_value_for_run.sql | 0 .../select_runs_and_specified_conditions.sql} | 25 +++++++++---------- 3 files changed, 12 insertions(+), 13 deletions(-) create mode 100644 sql/examples/get_all_conditions_for_run.sql create mode 100644 sql/examples/get_condition_value_for_run.sql rename sql/{select_conditions_as_table.sql => examples/select_runs_and_specified_conditions.sql} (66%) diff --git a/sql/examples/get_all_conditions_for_run.sql b/sql/examples/get_all_conditions_for_run.sql new file mode 100644 index 00000000..e69de29b diff --git a/sql/examples/get_condition_value_for_run.sql b/sql/examples/get_condition_value_for_run.sql new file mode 100644 index 00000000..e69de29b diff --git a/sql/select_conditions_as_table.sql b/sql/examples/select_runs_and_specified_conditions.sql similarity index 66% rename from sql/select_conditions_as_table.sql rename to sql/examples/select_runs_and_specified_conditions.sql index 6eebc4d9..b2bc222b 100644 --- a/sql/select_conditions_as_table.sql +++ b/sql/examples/select_runs_and_specified_conditions.sql @@ -1,15 +1,11 @@ -/*SELECT - runs.number run, - event_count_table.int_value event_count, - C2.float_value events_rate, - C3.int_value temperature -FROM runs - LEFT JOIN conditions event_count_table - ON event_count_table.run_number = runs.number AND event_count_table.condition_type_id = 1 - LEFT JOIN conditions C2 - ON C2.run_number = runs.number AND C2.condition_type_id = 2 - LEFT JOIN conditions C3 - ON C3.run_number = runs.number AND C3.condition_type_id = 3; +/* +Queries specified conditions over a range of runs. +Returns a convenient table where rows are run number +and columns are condition values. + +(!) note that types of values of conditions are specified manually: + 'event_count_table.int_value event_count' + So one has to */ @@ -31,5 +27,8 @@ FROM runs ON run_config_table.run_number = runs.number AND run_config_table.condition_type_id = 4 LEFT JOIN conditions polarization_angle_table ON polarization_angle_table.run_number = runs.number AND polarization_angle_table.condition_type_id = 56 - WHERE runs.number > 10000 AND event_count_table.int_value > 1000000 + WHERE + runs.number > 10000 + AND + event_count_table.int_value > 1000000 ;