Commit b2bd4950 authored by LAVENIER's avatar LAVENIER
Browse files

Merge branch 'develop' into feature/imagine

parents 9bfd1b85 92ed6f32
......@@ -15,24 +15,24 @@
<!-- other fields -->
<select alias="PARAMETER_FK" type="text"><![CDATA[
(CASE P.LABEL
WHEN 'SMALLER_MESH_GAUGE' THEN 'GEAR_LEGAL_MESH_SIZE'
WHEN 'HEADLINE_CUMULATIVE_LENGTH' THEN 'HEADLINE_LENGTH'
WHEN 'WING_LINE_FORM' THEN 'WING_LINE_CARAC'
WHEN 'SELECTIVE_DEVICE' THEN 'SELECTIVE_DEVICE_1'
WHEN UPPER('SMALLER_MESH_GAUGE') THEN UPPER('GEAR_LEGAL_MESH_SIZE')
WHEN UPPER('HEADLINE_CUMULATIVE_LENGTH') THEN UPPER('HEADLINE_LENGTH')
WHEN UPPER('WING_LINE_FORM') THEN UPPER('WING_LINE_CARAC')
WHEN UPPER('SELECTIVE_DEVICE') THEN UPPER('SELECTIVE_DEVICE_1')
ELSE P.LABEL
END)
]]></select>
<select alias="NAME" type="text">P.NAME</select>
<select alias="NUMERICAL_VALUE" type="number">CASE P.IS_BOOLEAN WHEN TRUE THEN null ELSE PGM.NUMERICAL_VALUE END)</select>
<select alias="NUMERICAL_VALUE" type="number">CASE P.IS_BOOLEAN WHEN TRUE THEN null ELSE PGM.NUMERICAL_VALUE END</select>
<select alias="QUALITATIVE_VALUE_NAME" type="number"><![CDATA[
CASE
WHEN (P.IS_BOOLEAN AND PGM.NUMERICAL_VALUE = 1) THEN 'Oui'
WHEN (P.IS_BOOLEAN AND PGM.NUMERICAL_VALUE = 0) THEN 'Non'
WHEN (P.LABEL = 'WING_LINE_FORM') THEN QV.NAME
WHEN (P.LABEL = UPPER('WING_LINE_FORM')) THEN QV.NAME
ELSE COALESCE(QV.LABEL, QV.NAME)
END
]]></select>
<select alias="CHARACTERISTICS" type="text">'PH'</select>
<select alias="CHARACTERISTICS" type="text">UPPER('PH')</select>
<select alias="UNITE" type="text">COALESCE(UNIT.NAME, 'Aucune')</select>
......@@ -65,17 +65,17 @@
<!-- other fields -->
<subselect alias="PARAMETER_FK" type="text"><![CDATA[
(CASE WHEN P.LABEL = 'FAKE' THEN 'TODO'
(CASE WHEN P.LABEL = UPPER('FAKE') THEN UPPER('TODO')
ELSE P.LABEL
END)
]]></subselect>
<subselect alias="NAME" type="text">P.NAME</subselect>
<subselect alias="NUMERICAL_VALUE" type="number">CASE P.IS_BOOLEAN WHEN 1 THEN null ELSE PGM.NUMERICAL_VALUE END</subselect>
<subselect alias="NUMERICAL_VALUE" type="number">CASE P.IS_BOOLEAN WHEN TRUE THEN null ELSE PGM.NUMERICAL_VALUE END</subselect>
<subselect alias="QUALITATIVE_VALUE_NAME" type="number"><![CDATA[
CASE
WHEN (P.IS_BOOLEAN AND PGM.NUMERICAL_VALUE = 1) THEN 'Oui'
WHEN (P.IS_BOOLEAN AND PGM.NUMERICAL_VALUE = 0) THEN 'Non'
WHEN (P.LABEL = 'WING_LINE_FORM') THEN QV.NAME
WHEN (P.LABEL = UPPER('WING_LINE_FORM')) THEN QV.NAME
ELSE COALESCE(QV.LABEL, QV.NAME)
END
]]></subselect>
......
......@@ -34,14 +34,8 @@
<select alias="ID_VRAC" type="hidden">CATCH_B.ID + SORTING_B.RANK_ORDER</select>
<select alias="NUM_VRAC" type="hidden">SORTING_B.RANK_ORDER</select>
<!-- <select alias="CATCH_CATEGORY" type="text"><![CDATA[(SELECT-->
<!-- DECODE(QV.ID, &discardQvId, 'DIS', &landingQvId, 'LAN', null)-->
<!-- FROM SORTING_MEASUREMENT_B SM-->
<!-- INNER JOIN QUALITATIVE_VALUE QV ON QV.ID=SM.QUALITATIVE_VALUE_FK-->
<!-- WHERE SM.BATCH_FK = SORTING_B.ID and SM.PMFM_FK=&catchCategoryPmfmId-->
<!-- )]]></select> -->
<select alias="CATCH_CATEGORY" type="text"><![CDATA[(SELECT
CASE QV.ID WHEN &discardQvId THEN 'DIS' WHEN &landingQvId THEN 'LAN' ELSE null END
CASE QV.ID WHEN &discardQvId THEN UPPER('DIS') WHEN &landingQvId THEN UPPER('LAN') ELSE null END
FROM SORTING_MEASUREMENT_B SM
INNER JOIN QUALITATIVE_VALUE QV ON QV.ID=SM.QUALITATIVE_VALUE_FK
WHERE SM.BATCH_FK = SORTING_B.ID and SM.PMFM_FK=&catchCategoryPmfmId
......@@ -49,18 +43,18 @@
<!-- other fields -->
<select alias="WEIGHT" type="number"><![CDATA[COALESCE(
(SELECT QM.NUMERICAL_VALUE FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SORTING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=1),
(CASE WHEN (SAMPLING_B.SAMPLING_RATIO IS NULL OR SAMPLING_B.SAMPLING_RATIO = 0) THEN NULL ELSE (SELECT QM.NUMERICAL_VALUE/SAMPLING_B.SAMPLING_RATIO FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SAMPLING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=1) END)
(SELECT QM.NUMERICAL_VALUE FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SORTING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=True),
(CASE WHEN (SAMPLING_B.SAMPLING_RATIO IS NULL OR SAMPLING_B.SAMPLING_RATIO = 0) THEN NULL ELSE (SELECT QM.NUMERICAL_VALUE/SAMPLING_B.SAMPLING_RATIO FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SAMPLING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=True) END)
)]]>
</select>
<select alias="SUBSAMPLE_WEIGHT" type="number"><![CDATA[COALESCE(
(SELECT QM.NUMERICAL_VALUE FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SAMPLING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=1),
(SELECT QM.NUMERICAL_VALUE FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SORTING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=1)
(SELECT QM.NUMERICAL_VALUE FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SAMPLING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=True),
(SELECT QM.NUMERICAL_VALUE FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SORTING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=True)
)]]>
</select>
<select alias="SUBSAMPLE_WEIGHT_PMFM_ID" type="number"><![CDATA[COALESCE(
(SELECT QM.PMFM_FK FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SAMPLING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=1),
(SELECT QM.PMFM_FK FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SORTING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=1)
(SELECT QM.PMFM_FK FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SAMPLING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=True),
(SELECT QM.PMFM_FK FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SORTING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=True)
)]]>
</select>
<select alias="SAMPLING_RATIO" type="number">SAMPLING_B.SAMPLING_RATIO</select>
......@@ -77,7 +71,7 @@
<from join="true">INNER JOIN BATCH SPECIE_B ON SPECIE_B.PARENT_BATCH_FK = CATCH_B.ID</from>
<from join="true">INNER JOIN TAXON_GROUP TG ON TG.ID = SPECIE_B.TAXON_GROUP_FK</from>
<from join="true">INNER JOIN BATCH SORTING_B ON SORTING_B.PARENT_BATCH_FK = SPECIE_B.ID</from>
<from join="true">LEFT OUTER JOIN BATCH SAMPLING_B ON SAMPLING_B.PARENT_BATCH_FK = SORTING_B.ID AND SAMPLING_B.LABEL LIKE 'SORTING_BATCH#%'</from>
<from join="true">LEFT OUTER JOIN BATCH SAMPLING_B ON SAMPLING_B.PARENT_BATCH_FK = SORTING_B.ID AND SAMPLING_B.LABEL LIKE UPPER('SORTING_BATCH#%')</from>
<where>1=1</where>
......
......@@ -18,7 +18,7 @@
<subselect alias="METHOD_NAME" type="text">REGEXP_REPLACE(M_LENGTH.NAME, '(Mesure|Estimation) par ', '$1 au ' || U_LENGTH.LABEL || ' par ')</subselect>
<from alias="SL">&amp;rawSpeciesListTableName</from>
<from join="true">INNER JOIN BATCH B ON B.PARENT_BATCH_FK=SL.SAMPLE_ID AND B.LABEL LIKE 'SORTING_BATCH_INDIVIDUAL#%'</from>
<from join="true">INNER JOIN BATCH B ON B.PARENT_BATCH_FK=SL.SAMPLE_ID AND B.LABEL LIKE UPPER('SORTING_BATCH_INDIVIDUAL#%')</from>
<from join="true">INNER JOIN SORTING_MEASUREMENT_B SM_LENGTH ON SM_LENGTH.BATCH_FK = B.ID and SM_LENGTH.PMFM_FK in (&amp;lengthTotalCmPmfmId, &amp;lengthCarapaceCmPmfmId)</from>
<from join="true">INNER JOIN PMFM PMFM_LENGTH ON PMFM_LENGTH.ID = SM_LENGTH.PMFM_FK</from>
<from join="true">INNER JOIN PARAMETER P_LENGTH ON P_LENGTH.ID = PMFM_LENGTH.PARAMETER_FK</from>
......@@ -53,4 +53,4 @@
</query>
</queries>
\ No newline at end of file
</queries>
......@@ -14,8 +14,7 @@
ET afficher les nom vernaculaires dans les UI (nécessaire pour ADAP) -->
<subselect alias="ESPECE" type="text">TN.COMMENTS</subselect>
<subselect alias="ESPECE_COM" type="text">TG.NAME</subselect>
<!-- <subselect alias="PRESENTATION" type="text">DECODE(SL.CATCH_CATEGORY, 'LAN', 'GUT - Eviscéré', null)</subselect>-->
<subselect alias="PRESENTATION" type="text">CASE SL.CATCH_CATEGORY WHEN 'LAN' THEN 'GUT - Eviscéré' ELSE null END</subselect>
<subselect alias="PRESENTATION" type="text">CASE SL.CATCH_CATEGORY WHEN UPPER('LAN') THEN CONCAT(UPPER('GUT - E'),'viscéré') ELSE null END</subselect>
<subselect alias="TAUX_ECH" type="number">
CASE
WHEN SL.SAMPLING_RATIO is not null THEN ROUND(SL.SAMPLING_RATIO, 7)
......@@ -30,7 +29,7 @@
<from alias="SL">&amp;rawSpeciesListTableName</from>
<from join="true">INNER JOIN BATCH SAMPLE_BATCH ON SAMPLE_BATCH.ID = SL.SAMPLE_ID</from>
<from join="true">INNER JOIN TAXON_GROUP TG ON TG.ID = SL.TAXON_GROUP_ID</from>
<from join="true">LEFT OUTER JOIN TAXON_NAME TN ON TN.REFERENCE_TAXON_FK = SL.REFERENCE_TAXON_ID AND TN.IS_REFERENT=1</from>
<from join="true">LEFT OUTER JOIN TAXON_NAME TN ON TN.REFERENCE_TAXON_FK = SL.REFERENCE_TAXON_ID AND TN.IS_REFERENT=True</from>
<from join="true">LEFT OUTER JOIN PMFM ON PMFM.ID = SL.SUBSAMPLE_WEIGHT_PMFM_ID</from>
<from join="true">LEFT OUTER JOIN METHOD ON METHOD.ID = PMFM.METHOD_FK</from>
</subquery>
......
......@@ -5,7 +5,7 @@
<query type="create" temp="false" table="&amp;stationTableName" option="DISTINCT">
<!-- PK -->
<select alias="TYPE" type="text">'HH'</select>
<select alias="TYPE" type="text">UPPER('HH')</select>
<select alias="ID_MAREE" type="number">T.TRIP_CODE</select>
<select alias="ID_OP" type="number">O.ID</select>
<select alias="NUM_OP" type="number"><![CDATA[(
......@@ -20,7 +20,6 @@
<select alias="DATE" type="hidden">COALESCE(O.FISHING_START_DATE_TIME, O.START_DATE_TIME)</select>
<!-- other fields -->
<!-- <select alias="DEROULEMENT_OP" type="text"><![CDATA[(SELECT DECODE(VUM.NUMERICAL_VALUE, 1, 'Normal', 0, 'Anormal', null) FROM VESSEL_USE_MEASUREMENT VUM WHERE VUM.OPERATION_FK=O.ID and VUM.PMFM_FK=&normalProgressPmfmId)]]></select>-->
<select alias="DEROULEMENT_OP" type="text"><![CDATA[(SELECT CASE VUM.NUMERICAL_VALUE WHEN 1 THEN 'Normal' WHEN 0 THEN 'Anormal' ELSE null END FROM VESSEL_USE_MEASUREMENT VUM WHERE VUM.OPERATION_FK=O.ID and VUM.PMFM_FK=&normalProgressPmfmId)]]></select>
<select alias="ETAT_MER" type="text"><![CDATA[
......
......@@ -10,8 +10,7 @@
<select alias="ID_VRAC" type="number">SL.ID_VRAC</select>
<select alias="NUM_VRAC" type="number">SL.NUM_VRAC</select>
<select alias="VRAC_HV" type="text">'Vrac'</select>
<!-- <select alias="PR_PNR" type="text">DECODE(SL.CATCH_CATEGORY, 'DIS', 'PNR', 'LAN', 'PR', null)</select>-->
<select alias="PR_PNR" type="text">CASE SL.CATCH_CATEGORY WHEN 'DIS' THEN 'PNR' WHEN 'LAN' THEN 'PR' ELSE null END</select>
<select alias="PR_PNR" type="text">CASE SL.CATCH_CATEGORY WHEN UPPER('DIS') THEN UPPER('PNR') WHEN UPPER('LAN') THEN UPPER('PR') ELSE null END</select>
<select alias="EXHAUSTIF" type="text">'Oui'</select><!-- Non saisissable dans SUMARiS -->
<select alias="TAUX_ECH" type="number">1.0</select><!-- Toujours à 1 dans ADAP -->
<select alias="POIDS_REF_VRAC" type="number">null</select>
......
......@@ -4,7 +4,7 @@
<query type="create" temp="false" table="&amp;tripTableName" option="DISTINCT">
<!-- PK -->
<select alias="TYPE" type="text">'TR'</select>
<select alias="TYPE" type="text">UPPER('TR')</select>
<select alias="PROJET" type="text">P.LABEL</select>
<select alias="ANNEE" type="number">EXTRACT(YEAR FROM T.RETURN_DATE_TIME)</select>
<select alias="ID_MAREE" type="number">T.ID</select>
......@@ -14,7 +14,8 @@
<select alias="PROJECT" type="hidden">P.LABEL</select>
<!-- other fields -->
<select alias="ID_NAVIRE" type="text">COALESCE(VRP.REGISTRATION_CODE, TO_CHAR(T.VESSEL_FK, '9999'))</select>
<select alias="ID_NAVIRE" type="text" group="oracle,hsqldb">COALESCE(VRP.REGISTRATION_CODE, TO_CHAR(T.VESSEL_FK))</select>
<select alias="ID_NAVIRE" type="text" group="pgsql">COALESCE(VRP.REGISTRATION_CODE, TO_CHAR(T.VESSEL_FK, '9999'))</select>
<select alias="NOM_NAVIRE" type="text">VF.NAME</select>
<select alias="LONGUEUR" type="number">VF.LENGTH_OVER_ALL / 100</select>
<select alias="PUISSANCE" type="number">VF.ADMINISTRATIVE_POWER</select>
......
......@@ -28,13 +28,8 @@
</select>
<!-- boolean -->
<!-- <select alias="&amp;pmfmLabel%pmfmAlias%" group="boolean%pmfmAlias%" type="text">-->
<!-- (SELECT DECODE(VUM.NUMERICAL_VALUE, 1, 'Y', 0, 'N')-->
<!-- FROM VESSEL_USE_MEASUREMENT VUM-->
<!-- WHERE VUM.OPERATION_FK=O.ID and VUM.PMFM_FK=&amp;pmfmId%pmfmAlias%)-->
<!-- </select> -->
<select alias="&amp;pmfmLabel%pmfmAlias%" group="boolean%pmfmAlias%" type="text">
(SELECT CASE VUM.NUMERICAL_VALUE WHEN 1 THEN 'Y' WHEN 0 THEN 'N' END
(SELECT CASE VUM.NUMERICAL_VALUE WHEN 1 THEN UPPER('Y') WHEN 0 THEN UPPER('N') END
FROM VESSEL_USE_MEASUREMENT VUM
WHERE VUM.OPERATION_FK=O.ID and VUM.PMFM_FK=&amp;pmfmId%pmfmAlias%)
</select>
......
......@@ -23,13 +23,8 @@
</select>
<!-- boolean -->
<!-- <select alias="&amp;pmfmLabel%pmfmAlias%" group="boolean%pmfmAlias%" type="text">-->
<!-- (SELECT DECODE(VUM.NUMERICAL_VALUE, 1, 'Y', 0, 'N')-->
<!-- FROM VESSEL_USE_MEASUREMENT VUM-->
<!-- WHERE VUM.TRIP_FK=T.ID and VUM.PMFM_FK=&amp;pmfmId%pmfmAlias%)-->
<!-- </select>-->
<select alias="&amp;pmfmLabel%pmfmAlias%" group="boolean%pmfmAlias%" type="text">
(SELECT CASE VUM.NUMERICAL_VALUE WHEN 1 THEN 'Y' WHEN 0 THEN 'N' END
(SELECT CASE VUM.NUMERICAL_VALUE WHEN 1 THEN UPPER('Y') WHEN 0 THEN UPPER('N') END
FROM VESSEL_USE_MEASUREMENT VUM
WHERE VUM.TRIP_FK=T.ID and VUM.PMFM_FK=&amp;pmfmId%pmfmAlias%)
</select>
......
......@@ -35,14 +35,8 @@
<!-- PK (new fields) -->
<select alias="SPECIES" type="text">TG.LABEL</select>
<!-- <select alias="CATCH_CATEGORY" type="text"><![CDATA[(SELECT-->
<!-- DECODE(QV.ID, &discardQvId, 'DIS', &landingQvId, 'LAN', null)-->
<!-- FROM SORTING_MEASUREMENT_B SM-->
<!-- INNER JOIN QUALITATIVE_VALUE QV ON QV.ID=SM.QUALITATIVE_VALUE_FK-->
<!-- WHERE SM.BATCH_FK = SORTING_B.ID and SM.PMFM_FK=&catchCategoryPmfmId-->
<!-- )]]></select>-->
<select alias="CATCH_CATEGORY" type="text"><![CDATA[(SELECT
CASE QV.ID WHEN &discardQvId THEN 'DIS' WHEN &landingQvId THEN 'LAN' ELSE null END
CASE QV.ID WHEN &discardQvId THEN UPPER('DIS') WHEN &landingQvId THEN UPPER('LAN') ELSE null END
FROM SORTING_MEASUREMENT_B SM
INNER JOIN QUALITATIVE_VALUE QV ON QV.ID=SM.QUALITATIVE_VALUE_FK
WHERE SM.BATCH_FK = SORTING_B.ID and SM.PMFM_FK=&catchCategoryPmfmId
......@@ -55,13 +49,13 @@
<!-- other fields -->
<select alias="WEIGHT" group="weight" type="number"><![CDATA[COALESCE(
(SELECT QM.NUMERICAL_VALUE FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SORTING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=1),
(CASE WHEN (SAMPLING_B.SAMPLING_RATIO IS NULL OR SAMPLING_B.SAMPLING_RATIO = 0) THEN NULL ELSE (SELECT QM.NUMERICAL_VALUE/SAMPLING_B.SAMPLING_RATIO FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SAMPLING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=1) END)
(SELECT QM.NUMERICAL_VALUE FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SORTING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=True),
(CASE WHEN (SAMPLING_B.SAMPLING_RATIO IS NULL OR SAMPLING_B.SAMPLING_RATIO = 0) THEN NULL ELSE (SELECT QM.NUMERICAL_VALUE/SAMPLING_B.SAMPLING_RATIO FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SAMPLING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=True) END)
)]]>
</select>
<select alias="SUBSAMPLING_WEIGHT" group="weight" type="number"><![CDATA[COALESCE(
(SELECT QM.NUMERICAL_VALUE FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SAMPLING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=1),
(SELECT QM.NUMERICAL_VALUE FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SORTING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=1)
(SELECT QM.NUMERICAL_VALUE FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SAMPLING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=True),
(SELECT QM.NUMERICAL_VALUE FROM QUANTIFICATION_MEASUREMENT_B QM WHERE QM.BATCH_FK=SORTING_B.ID and QM.IS_REFERENCE_QUANTIFICATION=True)
)]]>
</select>
<select alias="LENGTH_CODE" type="text">'mm'</select>
......@@ -75,11 +69,11 @@
<from join="true">INNER JOIN BATCH SPECIE_B ON SPECIE_B.PARENT_BATCH_FK = CATCH_B.ID</from>
<from join="true">INNER JOIN TAXON_GROUP TG ON TG.ID = SPECIE_B.TAXON_GROUP_FK</from>
<from join="true">INNER JOIN BATCH SORTING_B ON SORTING_B.PARENT_BATCH_FK = SPECIE_B.ID</from>
<from join="true">LEFT OUTER JOIN TAXON_NAME TN ON TN.REFERENCE_TAXON_FK = SPECIE_B.REFERENCE_TAXON_FK AND TN.IS_REFERENT=1</from>
<from join="true">LEFT OUTER JOIN BATCH SAMPLING_B ON SAMPLING_B.PARENT_BATCH_FK = SORTING_B.ID AND SAMPLING_B.LABEL LIKE 'SORTING_BATCH#%'</from>
<from join="true">LEFT OUTER JOIN TAXON_NAME TN ON TN.REFERENCE_TAXON_FK = SPECIE_B.REFERENCE_TAXON_FK AND TN.IS_REFERENT=True</from>
<from join="true">LEFT OUTER JOIN BATCH SAMPLING_B ON SAMPLING_B.PARENT_BATCH_FK = SORTING_B.ID AND SAMPLING_B.LABEL LIKE UPPER('SORTING_BATCH#%')</from>
<where>1=1</where>
<where operator="AND" group="excludeInvalidStation"><![CDATA[S.FISHING_VALIDITY != 'I']]></where>
<where operator="AND" group="excludeInvalidStation"><![CDATA[S.FISHING_VALIDITY != UPPER('I')]]></where>
<orderby direction="ASC">S.STATION_NUMBER, SAMPLE_RANK_ORDER</orderby>
......
......@@ -29,14 +29,13 @@
<subselect alias="SAMPLE_ID" type="number">SL.SAMPLE_ID</subselect>
<subselect alias="ID" type="number">B.ID</subselect>
<subselect alias="SEX" type="text">(SELECT QV.LABEL FROM SORTING_MEASUREMENT_B SM INNER JOIN QUALITATIVE_VALUE QV ON QV.ID=SM.QUALITATIVE_VALUE_FK WHERE SM.BATCH_FK = B.ID and SM.PMFM_FK=&amp;sexPmfmId)</subselect>
<!-- <subselect alias="LENGTH_CLASS" type="number">CAST( DECODE(PMFM_LENGTH.UNIT_FK, &amp;centimeterUnitId, SM_LENGTH.NUMERICAL_VALUE*10, &amp;millimeterUnitId, SM_LENGTH.NUMERICAL_VALUE, null) AS INTEGER)</subselect>-->
<subselect alias="LENGTH_CLASS" type="number">CAST(CASE PMFM_LENGTH.UNIT_FK WHEN &amp;centimeterUnitId THEN SM_LENGTH.NUMERICAL_VALUE*10 WHEN &amp;millimeterUnitId THEN SM_LENGTH.NUMERICAL_VALUE ELSE null END AS INTEGER)</subselect>
<subselect alias="INDIVIDUAL_COUNT" type="number">COALESCE(B.INDIVIDUAL_COUNT,1)</subselect>
<subselect alias="COMMENTS" type="text">B.COMMENTS</subselect>
<subselect alias="PARAMETER_LABEL" type="text">P_LENGTH.LABEL</subselect>
<from alias="SL">&amp;rawSpeciesListTableName</from>
<from join="true">INNER JOIN BATCH B ON B.PARENT_BATCH_FK=SL.SAMPLE_ID AND B.LABEL LIKE 'SORTING_BATCH_INDIVIDUAL#%'</from>
<from join="true">INNER JOIN BATCH B ON B.PARENT_BATCH_FK=SL.SAMPLE_ID AND B.LABEL LIKE UPPER('SORTING_BATCH_INDIVIDUAL#%')</from>
<from join="true">INNER JOIN SORTING_MEASUREMENT_B SM_LENGTH ON SM_LENGTH.BATCH_FK = B.ID and SM_LENGTH.PMFM_FK in (&amp;lengthTotalCmPmfmId, &amp;lengthCarapaceCmPmfmId)</from>
<from join="true">INNER JOIN PMFM PMFM_LENGTH ON PMFM_LENGTH.ID = SM_LENGTH.PMFM_FK</from>
<from join="true">INNER JOIN PARAMETER P_LENGTH ON P_LENGTH.ID = PMFM_LENGTH.PARAMETER_FK</from>
......@@ -44,7 +43,7 @@
</with>
<!-- PK -->
<select alias="RECORD_TYPE" type="text">'HL'</select>
<select alias="RECORD_TYPE" type="text">UPPER('HL')</select>
<select alias="SAMPLING_TYPE" type="text">SL.SAMPLING_TYPE</select>
<select alias="LANDING_COUNTRY" type="text">SL.LANDING_COUNTRY</select>
<select alias="VESSEL_FLAG_COUNTRY" type="text">SL.VESSEL_FLAG_COUNTRY</select>
......@@ -75,9 +74,9 @@
<groupby>
SAMPLING_TYPE, LANDING_COUNTRY, VESSEL_FLAG_COUNTRY, YEAR, PROJECT, TRIP_CODE, STATION_NUMBER, SPECIES,
CATCH_CATEGORY, LANDING_CATEGORY, COMMERCIAL_SIZE_CATEGORY_SCALE, COMMERCIAL_SIZE_CATEGORY, SUBSAMPLING_CATEGORY, SAMPLE_ID
CATCH_CATEGORY, LANDING_CATEGORY, COMMERCIAL_SIZE_CATEGORY_SCALE, COMMERCIAL_SIZE_CATEGORY, SUBSAMPLING_CATEGORY, SL.SAMPLE_ID
</groupby>
<groupby group="sex">SEX, INDIVIDUAL_SEX</groupby>
<groupby group="sex">SL.SEX, INDIVIDUAL_SEX</groupby>
<groupby group="lengthClass">LENGTH_CLASS</groupby>
......
......@@ -25,7 +25,7 @@
<query type="create" temp="false" table="&amp;speciesListTableName" option="DISTINCT">
<!-- PK (inherited) -->
<select alias="RECORD_TYPE" type="text">'SL'</select>
<select alias="RECORD_TYPE" type="text">UPPER('SL')</select>
<select alias="SAMPLING_TYPE" type="text">SL.SAMPLING_TYPE</select>
<select alias="LANDING_COUNTRY" type="text">SL.LANDING_COUNTRY</select>
<select alias="VESSEL_FLAG_COUNTRY" type="text">SL.VESSEL_FLAG_COUNTRY</select>
......@@ -48,7 +48,7 @@
<select alias="LENGTH_CODE" group="lengthCode" type="text">SL.LENGTH_CODE</select>
<!-- need to link other tables -->
<select alias="SAMPLE_IDS" group="hsqldb" type="hidden">ARRAY_AGG(SL.SAMPLE_ID)</select>
<select alias="SAMPLE_IDS" group="hsqldb,pgsql" type="hidden">ARRAY_AGG(SL.SAMPLE_ID)</select>
<select alias="SAMPLE_IDS" group="oracle" type="hidden">LISTAGG(SL.SAMPLE_ID, ',')</select>
<from alias="SL">&amp;rawSpeciesListTableName</from>
......@@ -63,4 +63,4 @@
</query>
</queries>
\ No newline at end of file
</queries>
......@@ -25,7 +25,7 @@
<query type="create" temp="false" table="&amp;stationTableName" option="DISTINCT">
<!-- PK -->
<select alias="RECORD_TYPE" type="text">'HH'</select>
<select alias="RECORD_TYPE" type="text">UPPER('HH')</select>
<select alias="SAMPLING_TYPE" type="text">T.SAMPLING_TYPE</select>
<select alias="LANDING_COUNTRY" type="text">T.LANDING_COUNTRY</select>
<select alias="VESSEL_FLAG_COUNTRY" type="text">T.VESSEL_FLAG_COUNTRY</select>
......@@ -35,9 +35,8 @@
<select alias="STATION_NUMBER" type="number">O.ID</select>
<!-- other fields -->
<!-- <select alias="FISHING_VALIDITY" type="text"><![CDATA[(SELECT DECODE(VUM.NUMERICAL_VALUE, 1, 'V', 0, 'I', null) FROM VESSEL_USE_MEASUREMENT VUM WHERE VUM.OPERATION_FK=O.ID and VUM.PMFM_FK=&normalProgressPmfmId)]]></select>-->
<select alias="FISHING_VALIDITY" type="text"><![CDATA[(SELECT CASE VUM.NUMERICAL_VALUE WHEN 1 THEN 'V' WHEN 0 THEN 'I' ELSE null END FROM VESSEL_USE_MEASUREMENT VUM WHERE VUM.OPERATION_FK=O.ID and VUM.PMFM_FK=&normalProgressPmfmId)]]></select>
<select alias="AGGREGATION_LEVEL" type="text">'H'</select>
<select alias="FISHING_VALIDITY" type="text"><![CDATA[(SELECT CASE VUM.NUMERICAL_VALUE WHEN 1 THEN UPPER('V') WHEN 0 THEN UPPER('I') ELSE null END FROM VESSEL_USE_MEASUREMENT VUM WHERE VUM.OPERATION_FK=O.ID and VUM.PMFM_FK=&normalProgressPmfmId)]]></select>
<select alias="AGGREGATION_LEVEL" type="text">UPPER('H')</select>
<select alias="CATCH_REGISTRATION" type="text">'All'</select><!-- TODO : check batch lan/dis -->
<select alias="SPECIES_REGISTRATION" type="text">'Par'</select><!-- TODO : check batch exhaustiveness -->
<select alias="DATE" group="date" type="text">TO_CHAR(COALESCE(O.FISHING_START_DATE_TIME, O.START_DATE_TIME), 'YYYY-MM-DD')</select>
......
......@@ -25,11 +25,11 @@
<query type="create" temp="false" table="&amp;tripTableName" option="DISTINCT">
<!-- PK -->
<select alias="RECORD_TYPE" type="text">'TR'</select>
<select alias="SAMPLING_TYPE" type="text">'S'</select>
<select alias="RECORD_TYPE" type="text">UPPER('TR')</select>
<select alias="SAMPLING_TYPE" type="text">UPPER('S')</select>
<select alias="LANDING_COUNTRY" type="text">PL.LABEL</select>
<select alias="VESSEL_FLAG_COUNTRY" type="text">VL.LABEL</select>
<select alias="YEAR" type="number">EXTRACT(YEAR FROM T.RETURN_DATE_TIME)</select>
<select alias="YEAR" type="number">CAST (EXTRACT(YEAR FROM T.RETURN_DATE_TIME) AS INT)</select>
<select alias="PROJECT" type="text">P.LABEL</select>
<select alias="TRIP_CODE" type="number">T.ID</select>
......
......@@ -30,7 +30,7 @@
<select alias="NUMBER_AT_LENGTH" type="number">SUM(B.INDIVIDUAL_COUNT)</select>
<select alias="IS_DEAD" type="text"><![CDATA[(
SELECT
CASE SM.NUMERICAL_VALUE WHEN 0 THEN 'N' WHEN 1 THEN 'Y' ELSE null END
CASE SM.NUMERICAL_VALUE WHEN 0 THEN UPPER('N') WHEN 1 THEN UPPER('Y') ELSE null END
FROM
SORTING_MEASUREMENT_B SM
WHERE SM.BATCH_FK=B.ID and SM.PMFM_FK=&isDeadPmfmId
......
......@@ -25,7 +25,7 @@
<query type="create" temp="false" table="&amp;strategyMonitoringTableName" option="DISTINCT">
<!-- PK -->
<select alias="RECORD_TYPE" type="text">'SM'</select>
<select alias="RECORD_TYPE" type="text">UPPER('SM')</select>
<select alias="PROJECT" type="text">ST.PROJECT</select>
<select alias="STRATEGY" type="text">ST.STRATEGY</select>
......@@ -70,4 +70,4 @@
</query>
</queries>
\ No newline at end of file
</queries>
......@@ -25,7 +25,7 @@
<query type="create" temp="false" table="&amp;strategyTableName" option="DISTINCT">
<!-- PK -->
<select alias="RECORD_TYPE" type="text">'ST'</select>
<select alias="RECORD_TYPE" type="text">UPPER('ST')</select>
<select alias="PROJECT" type="text">P.LABEL</select>
<select alias="STRATEGY" type="text">S.LABEL</select>
<select alias="STRATEGY_NAME" type="text">S.NAME</select>
......
......@@ -36,8 +36,8 @@
<subselect alias="COMMENTS" type="text">SA.COMMENTS</subselect>
<from alias="S">&amp;stationTableName</from>
<from join="true">INNER JOIN SAMPLE SA ON SA.OPERATION_FK = S.STATION_NUMBER AND SA.LABEL LIKE 'INDIVIDUAL_RELEASE#%'</from>
<from join="true">INNER JOIN SAMPLE PARENT_SA ON PARENT_SA.ID = SA.PARENT_SAMPLE_FK AND PARENT_SA.LABEL LIKE 'SURVIVAL_TEST#%'</from>
<from join="true">INNER JOIN SAMPLE SA ON SA.OPERATION_FK = S.STATION_NUMBER AND SA.LABEL LIKE UPPER('INDIVIDUAL_RELEASE#%')</from>
<from join="true">INNER JOIN SAMPLE PARENT_SA ON PARENT_SA.ID = SA.PARENT_SAMPLE_FK AND PARENT_SA.LABEL LIKE UPPER('SURVIVAL_TEST#%')</from>
<from join="true">INNER JOIN SAMPLE_MEASUREMENT SM ON SM.SAMPLE_FK = SA.ID</from>
<from join="true">LEFT OUTER JOIN PMFM ON PMFM.ID = SM.PMFM_FK</from>
<from join="true">LEFT OUTER JOIN QUALITATIVE_VALUE SQV ON SQV.ID=SM.QUALITATIVE_VALUE_FK</from>
......@@ -54,8 +54,8 @@
<subselect alias="COMMENTS" type="text">null</subselect>
<from alias="S">&amp;stationTableName</from>
<from join="true">INNER JOIN SAMPLE CHILD_SA ON CHILD_SA.OPERATION_FK = S.STATION_NUMBER AND CHILD_SA.LABEL LIKE 'INDIVIDUAL_RELEASE#%'</from>
<from join="true">INNER JOIN SAMPLE SA ON SA.ID = CHILD_SA.PARENT_SAMPLE_FK AND SA.LABEL LIKE 'SURVIVAL_TEST#%'</from>
<from join="true">INNER JOIN SAMPLE CHILD_SA ON CHILD_SA.OPERATION_FK = S.STATION_NUMBER AND CHILD_SA.LABEL LIKE UPPER('INDIVIDUAL_RELEASE#%')</from>
<from join="true">INNER JOIN SAMPLE SA ON SA.ID = CHILD_SA.PARENT_SAMPLE_FK AND SA.LABEL LIKE UPPER('SURVIVAL_TEST#%')</from>
<from join="true">INNER JOIN SAMPLE_MEASUREMENT SM ON SM.SAMPLE_FK = SA.ID</from>
<from join="true">LEFT OUTER JOIN PMFM ON PMFM.ID = SM.PMFM_FK</from>
<from join="true">LEFT OUTER JOIN QUALITATIVE_VALUE SQV ON SQV.ID=SM.QUALITATIVE_VALUE_FK</from>
......@@ -67,7 +67,7 @@
</with>
<!-- PK -->
<select alias="RECORD_TYPE" type="text">'RL'</select>
<select alias="RECORD_TYPE" type="text">UPPER('RL')</select>
<select alias="SAMPLING_TYPE" type="text">S.SAMPLING_TYPE</select>
<select alias="LANDING_COUNTRY" type="text">S.LANDING_COUNTRY</select>
<select alias="VESSEL_FLAG_COUNTRY" type="text">S.VESSEL_FLAG_COUNTRY</select>
......@@ -80,24 +80,21 @@
<!-- SURVIVAL TEST -->
<select alias="SPECIES_CODE" type="number">TN.LABEL</select>
<select alias="SPECIES_NAME" type="number">TN.NAME</select>
<!-- <select alias="TAG_ID" type="text">MAX(DECODE(T.PMFM_LABEL, 'TAG_ID', T.ALPHA_VALUE))</select>-->
<select alias="TAG_ID" type="text">MAX(CASE T.PMFM_LABEL WHEN 'TAG_ID' THEN T.ALPHA_VALUE END)</select>
<select alias="TAG_ID" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('TAG_ID') THEN T.ALPHA_VALUE END)</select>
<!-- INDIVIDUAL RELEASE -->
<!-- <select alias="MEASURE_TIME" type="text">MAX(DECODE(T.PMFM_LABEL, 'MEASURE_TIME', TIMESTAMP(REPLACE(REPLACE(T.ALPHA_VALUE, 'T', ' '), 'Z', ''))))</select>-->
<select alias="MEASURE_TIME" type="text">MAX(CASE T.PMFM_LABEL WHEN 'MEASURE_TIME' THEN TIMESTAMP(REPLACE(REPLACE(T.ALPHA_VALUE, 'T', ' '), 'Z', '')) END)</select>
<!-- <select alias="LATITUDE" type="text">MAX(DECODE(T.PMFM_LABEL, 'LATITUDE', T.NUM_VALUE))</select>-->
<select alias="LATITUDE" type="text">MAX(CASE T.PMFM_LABEL WHEN 'LATITUDE' THEN T.NUM_VALUE END)</select>
<!-- <select alias="LONGITUDE" type="text">MAX(DECODE(T.PMFM_LABEL, 'LONGITUDE', T.NUM_VALUE))</select>-->
<select alias="LONGITUDE" type="text">MAX(CASE T.PMFM_LABEL WHEN 'LONGITUDE' THEN T.NUM_VALUE))</select>
<select alias="MEASURE_TIME" type="text" group="oracle,hsqldb">MAX(CASE T.PMFM_LABEL WHEN 'MEASURE_TIME' THEN TIMESTAMP(REPLACE(REPLACE(T.ALPHA_VALUE, 'T', ' '), 'Z', '')) END)</select>
<select alias="MEASURE_TIME" type="text" group="pgsql">MAX(CASE T.PMFM_LABEL WHEN UPPER('MEASURE_TIME') THEN TO_TIMESTAMP(REPLACE(REPLACE(T.ALPHA_VALUE, 'T', ' '), 'Z', ''), 'YYYY-MM-dd HH24:MI:SS') END)</select>
<select alias="LATITUDE" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('LATITUDE') THEN T.NUM_VALUE END)</select>
<select alias="LONGITUDE" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('LONGITUDE') THEN T.NUM_VALUE END)</select>
<select alias="COMMENTS" type="text">MAX(T.COMMENTS)</select>
<from alias="S">&amp;stationTableName</from>
<from join="true">INNER JOIN SAMPLE_WITH_MEAS T ON T.STATION_NUMBER = S.STATION_NUMBER</from>
<from join="true">LEFT OUTER JOIN TAXON_NAME TN ON TN.REFERENCE_TAXON_FK = T.REFERENCE_TAXON_FK AND TN.IS_REFERENT= 1</from>
<from join="true">LEFT OUTER JOIN TAXON_NAME TN ON TN.REFERENCE_TAXON_FK = T.REFERENCE_TAXON_FK AND TN.IS_REFERENT=True</from>
<groupby>
RECORD_TYPE, SAMPLING_TYPE, LANDING_COUNTRY, VESSEL_FLAG_COUNTRY, YEAR, PROJECT,
TRIP_CODE, STATION_NUMBER, INDIVIDUAL_ID, SPECIES_CODE, SPECIES_NAME
TRIP_CODE, S.STATION_NUMBER, INDIVIDUAL_ID, SPECIES_CODE, SPECIES_NAME
</groupby>
</query>
......
......@@ -35,7 +35,7 @@
<subselect alias="NUM_VALUE" type="number">SM.NUMERICAL_VALUE</subselect>
<from alias="S">&amp;stationTableName</from>
<from join="true">INNER JOIN SAMPLE SA ON SA.OPERATION_FK = S.STATION_NUMBER AND SA.LABEL LIKE 'SURVIVAL_TEST#%'</from>
<from join="true">INNER JOIN SAMPLE SA ON SA.OPERATION_FK = S.STATION_NUMBER AND SA.LABEL LIKE UPPER('SURVIVAL_TEST#%')</from>
<from join="true">INNER JOIN SAMPLE_MEASUREMENT SM ON SM.SAMPLE_FK = SA.ID</from>
<from join="true">LEFT OUTER JOIN PMFM ON PMFM.ID = SM.PMFM_FK</from>
<from join="true">LEFT OUTER JOIN QUALITATIVE_VALUE SQV ON SQV.ID=SM.QUALITATIVE_VALUE_FK</from>
......@@ -51,8 +51,8 @@
<subselect alias="NUM_VALUE" type="number">SM.NUMERICAL_VALUE</subselect>
<from alias="S">&amp;stationTableName</from>
<from join="true">INNER JOIN SAMPLE PARENT_SA ON PARENT_SA.OPERATION_FK = S.STATION_NUMBER AND PARENT_SA.LABEL LIKE 'SURVIVAL_TEST#%'</from>
<from join="true">INNER JOIN SAMPLE SA ON SA.PARENT_SAMPLE_FK = PARENT_SA.ID AND SA.LABEL LIKE 'INDIVIDUAL_MONITORING#%'</from>
<from join="true">INNER JOIN SAMPLE PARENT_SA ON PARENT_SA.OPERATION_FK = S.STATION_NUMBER AND PARENT_SA.LABEL LIKE UPPER('SURVIVAL_TEST#%')</from>
<from join="true">INNER JOIN SAMPLE SA ON SA.PARENT_SAMPLE_FK = PARENT_SA.ID AND SA.LABEL LIKE UPPER('INDIVIDUAL_MONITORING#%')</from>
<from join="true">INNER JOIN SAMPLE_MEASUREMENT SM ON SM.SAMPLE_FK = SA.ID</from>
<from join="true">LEFT OUTER JOIN PMFM ON PMFM.ID = SM.PMFM_FK</from>
<from join="true">LEFT OUTER JOIN QUALITATIVE_VALUE SQV ON SQV.ID=SM.QUALITATIVE_VALUE_FK</from>
......@@ -61,7 +61,7 @@
</subquery>
</with>
<!-- PK -->
<select alias="RECORD_TYPE" type="text">'ST'</select>
<select alias="RECORD_TYPE" type="text">UPPER('ST')</select>
<select alias="SAMPLING_TYPE" type="text">S.SAMPLING_TYPE</select>
<select alias="LANDING_COUNTRY" type="text">S.LANDING_COUNTRY</select>
<select alias="VESSEL_FLAG_COUNTRY" type="text">S.VESSEL_FLAG_COUNTRY</select>
......@@ -75,39 +75,41 @@
<select alias="SPECIES_CODE" type="number">TN.LABEL</select>
<select alias="SPECIES_NAME" type="number">TN.NAME</select>
<select alias="SCORING_DATE" type="number">T.SAMPLE_DATE</select>
<select alias="PICKING_TIME" type="text">MAX(CASE T.PMFM_LABEL WHEN 'PICKING_TIME' THEN T.ALPHA_VALUE END)</select>
<select alias="VITALITY_SCORE" type="text">MAX(CASE T.PMFM_LABEL WHEN 'VITALITY_SCORE' THEN T.ALPHA_VALUE END)</select>
<select alias="REFLEX_TAIL_GRAB" type="text">MAX(CASE T.PMFM_LABEL WHEN 'REFLEX_TAIL_GRAB' THEN T.ALPHA_VALUE END)</select>
<select alias="REFLEX_STARTLE_TOUCH" type="text">MAX(CASE T.PMFM_LABELWHEN 'REFLEX_STARTLE_TOUCH'THEN T.ALPHA_VALUE END)</select>
<select alias="REFLEX_SPIRACLES" type="text">MAX(CASE T.PMFM_LABEL WHEN 'REFLEX_SPIRACLES' THEN T.ALPHA_VALUE END)</select>
<select alias="REFLEX_BODY_FLEX" type="text">MAX(CASE T.PMFM_LABEL WHEN 'REFLEX_BODY_FLEX' THEN T.ALPHA_VALUE END)</select>
<select alias="INJURIES_OPEN_WOUNDS" type="text">MAX(CASE T.PMFM_LABEL WHEN 'INJURIES_OPEN_WOUNDS' THEN T.ALPHA_VALUE END)</select>
<select alias="INJURIES_HEAD" type="text">MAX(CASE T.PMFM_LABEL WHEN 'INJURIES_HEAD' THEN T.ALPHA_VALUE END)</select>
<select alias="INJURIES_BODY" type="text">MAX(CASE T.PMFM_LABEL WHEN 'INJURIES_BODY' THEN T.ALPHA_VALUE END)</select>
<select alias="INJURIES_TAIL" type="text">MAX(CASE T.PMFM_LABEL WHEN 'INJURIES_TAIL' THEN T.ALPHA_VALUE END)</select>
<select alias="INJURIES_FIN_DAMAGE" type="text">MAX(CASE T.PMFM_LABEL WHEN 'INJURIES_FIN_DAMAGE' THEN T.ALPHA_VALUE END)</select>
<select alias="SEX" type="text">MAX(CASE T.PMFM_LABEL WHEN 'SEX' THEN T.ALPHA_VALUE END)</select>
<select alias="LENGTH_TOTAL_CM" type="text">MAX(CASE T.PMFM_LABEL WHEN 'LENGTH_TOTAL_CM' THEN T.NUM_VALUE END)</select>
<select alias="TAG_ID" type="text">MAX(CASE T.PMFM_LABEL WHEN 'TAG_ID' THEN T.ALPHA_VALUE END)</select>
<select alias="MONITORING_BOX_ID" type="text">MAX(CASE T.PMFM_LABEL WHEN 'MONITORING_BOX_ID' THEN T.ALPHA_VALUE END)</select>
<select alias="PICKING_TIME" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('PICKING_TIME') THEN T.ALPHA_VALUE END)</select>
<select alias="VITALITY_SCORE" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('VITALITY_SCORE') THEN T.ALPHA_VALUE END)</select>
<select alias="REFLEX_TAIL_GRAB" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('REFLEX_TAIL_GRAB') THEN T.ALPHA_VALUE END)</select>
<select alias="REFLEX_STARTLE_TOUCH" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('REFLEX_STARTLE_TOUCH') THEN T.ALPHA_VALUE END)</select>
<select alias="REFLEX_SPIRACLES" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('REFLEX_SPIRACLES') THEN T.ALPHA_VALUE END)</select>
<select alias="REFLEX_BODY_FLEX" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('REFLEX_BODY_FLEX') THEN T.ALPHA_VALUE END)</select>
<select alias="INJURIES_OPEN_WOUNDS" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('INJURIES_OPEN_WOUNDS') THEN T.ALPHA_VALUE END)</select>
<select alias="INJURIES_HEAD" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('INJURIES_HEAD') THEN T.ALPHA_VALUE END)</select>
<select alias="INJURIES_BODY" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('INJURIES_BODY') THEN T.ALPHA_VALUE END)</select>
<select alias="INJURIES_TAIL" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('INJURIES_TAIL') THEN T.ALPHA_VALUE END)</select>
<select alias="INJURIES_FIN_DAMAGE" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('INJURIES_FIN_DAMAGE') THEN T.ALPHA_VALUE END)</select>
<select alias="SEX" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('SEX') THEN T.ALPHA_VALUE END)</select>
<select alias="LENGTH_TOTAL_CM" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('LENGTH_TOTAL_CM') THEN T.NUM_VALUE END)</select>
<select alias="TAG_ID" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('TAG_ID') THEN T.ALPHA_VALUE END)</select>
<select alias="MONITORING_BOX_ID" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('MONITORING_BOX_ID') THEN T.ALPHA_VALUE END)</select>
<!-- INDIVIDUAL MONITORING -->
<select alias="IS_DEAD" type="text">MAX(CASE T.PMFM_LABEL WHEN 'IS_DEAD' THEN (CASE T.NUM_VALUE WHEN 1 THEN 'Y' WHEN 0 THEN 'N' END) END)</select>
<select alias="DEATH_TIME" type="text">MAX(CASE T.PMFM_LABEL WHEN 'DEATH_TIME' THEN TIMESTAMP(REPLACE(REPLACE(T.ALPHA_VALUE, 'T', ' '), 'Z', '')) END)</select>
<select alias="VERTEBRAL_COLUMN_ANALYSIS" type="text">MAX(CASE T.PMFM_LABEL WHEN 'VERTEBRAL_COLUMN_ANALYSIS' THEN (CASE T.NUM_VALUE WHEN 1 THEN 'Y' WHEN 0 THEN 'N' END) END)</select>
<select alias="MEASURE_TIME" type="text">MAX(CASE T.PMFM_LABEL WHEN 'MEASURE_TIME' THEN TIMESTAMP(REPLACE(REPLACE(T.ALPHA_VALUE, 'T', ' '), 'Z', '')) END)</select>
<select alias="DO_PCT" type="text">MAX(CASE T.PMFM_LABEL WHEN 'DO_PCT' THEN T.NUM_VALUE END)</select>
<select alias="SAL_PSU" type="text">MAX(CASE T.PMFM_LABEL WHEN 'SAL_PSU' THEN T.NUM_VALUE END)</select>
<select alias="WATER_TEMP_C" type="text">MAX(CASE T.PMFM_LABEL WHEN 'WATER_TEMP_C' THEN T.NUM_VALUE END)</select>
<select alias="AIR_TEMP_C" type="text">MAX(CASE T.PMFM_LABEL WHEN 'AIR_TEMP_C' THEN T.NUM_VALUE END)</select>
<select alias="CLOUD_COVER_PCT" type="text">MAX(CASE T.PMFM_LABEL WHEN 'CLOUD_COVER_PCT' THEN T.NUM_VALUE END)</select>
<select alias="COMMENTS" type="text">MAX(CASE T.PMFM_LABEL WHEN 'CLOUD_COVER_PCT' THEN T.NUM_VALUE END)</select>
<select alias="IS_DEAD" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('IS_DEAD') THEN (CASE T.NUM_VALUE WHEN 1 THEN UPPER('Y') WHEN 0 THEN UPPER('N') END) END)</select>
<select alias="DEATH_TIME" type="text" group="hsqldb,oracle">MAX(CASE T.PMFM_LABEL WHEN 'DEATH_TIME' THEN TIMESTAMP(REPLACE(REPLACE(T.ALPHA_VALUE, 'T', ' '), 'Z', '')) END)</select>
<select alias="DEATH_TIME" type="text" group="pgsql">MAX(CASE T.PMFM_LABEL WHEN UPPER('DEATH_TIME') THEN TO_TIMESTAMP(REPLACE(REPLACE(T.ALPHA_VALUE, 'T', ' '), 'Z', ''), 'YYYY-MM-dd HH24:MI:SS') END)</select>
<select alias="VERTEBRAL_COLUMN_ANALYSIS" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('VERTEBRAL_COLUMN_ANALYSIS') THEN (CASE T.NUM_VALUE WHEN 1 THEN 'Y' WHEN 0 THEN 'N' END) END)</select>
<select alias="MEASURE_TIME" type="text" group="hsqldb,oracle">MAX(CASE T.PMFM_LABEL WHEN 'MEASURE_TIME' THEN TIMESTAMP(REPLACE(REPLACE(T.ALPHA_VALUE, 'T', ' '), 'Z', '')) END)</select>
<select alias="MEASURE_TIME" type="text" group="pgsql">MAX(CASE T.PMFM_LABEL WHEN UPPER('MEASURE_TIME') THEN TO_TIMESTAMP(REPLACE(REPLACE(T.ALPHA_VALUE, 'T', ' '), 'Z', ''), 'YYYY-MM-dd HH24:MI:SS') END)</select>
<select alias="DO_PCT" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('DO_PCT') THEN T.NUM_VALUE END)</select>
<select alias="SAL_PSU" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('SAL_PSU') THEN T.NUM_VALUE END)</select>
<select alias="WATER_TEMP_C" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('WATER_TEMP_C') THEN T.NUM_VALUE END)</select>
<select alias="AIR_TEMP_C" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('AIR_TEMP_C') THEN T.NUM_VALUE END)</select>
<select alias="CLOUD_COVER_PCT" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('CLOUD_COVER_PCT') THEN T.NUM_VALUE END)</select>
<select alias="COMMENTS" type="text">MAX(CASE T.PMFM_LABEL WHEN UPPER('CLOUD_COVER_PCT') THEN T.NUM_VALUE END)</select>
<from alias="S">&amp;stationTableName</from>
<from join="true">INNER JOIN SAMPLE_WITH_MEAS T ON T.STATION_NUMBER = S.STATION_NUMBER</from>
<from join="true">LEFT OUTER JOIN TAXON_NAME TN ON TN.REFERENCE_TAXON_FK = T.REFERENCE_TAXON_FK AND TN.IS_REFERENT= 1</from>
<from join="true">LEFT OUTER JOIN TAXON_NAME TN ON TN.REFERENCE_TAXON_FK = T.REFERENCE_TAXON_FK AND TN.IS_REFERENT=True</from>
<groupby>
RECORD_TYPE, SAMPLING_TYPE, LANDING_COUNTRY, VESSEL_FLAG_COUNTRY, YEAR, PROJECT, TRIP_CODE, STATION_NUMBER,
RECORD_TYPE, SAMPLING_TYPE, LANDING_COUNTRY, VESSEL_FLAG_COUNTRY, YEAR, PROJECT, TRIP_CODE, S.STATION_NUMBER,
INDIVIDUAL_ID, SPECIES_CODE, SPECIES_NAME, SCORING_DATE
</groupby>