Mercurial > dive4elements > river
changeset 9095:1b24fdbf7fe2
Fixed flow velocity query by distinct clause to avoid duplicates
author | mschaefer |
---|---|
date | Fri, 25 May 2018 16:03:15 +0200 |
parents | 5488166d32ee |
children | 9bd4505a20dc |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/FlowVelocityModelKmValueFinder.java |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/FlowVelocityModelKmValueFinder.java Fri May 25 15:41:51 2018 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/sinfo/tkhcalculation/FlowVelocityModelKmValueFinder.java Fri May 25 16:03:15 2018 +0200 @@ -52,7 +52,7 @@ * (Might be several 10000 rows if many stations and large q range) */ private static final String SQL_SELECT_ALL = // - "SELECT fvmv.station AS station, fvmv.q AS q, fvmv.main_channel AS vmain, fvmv.shear_stress AS tau" + "SELECT DISTINCT fvmv.station AS station, fvmv.q AS q, fvmv.main_channel AS vmain, fvmv.shear_stress AS tau" + " FROM (discharge_zone dz INNER JOIN flow_velocity_model fvm ON dz.id = fvm.discharge_zone_id)" + " INNER JOIN flow_velocity_model_values fvmv ON fvm.id = fvmv.flow_velocity_model_id" + " WHERE (dz.river_id = :river_id) AND (fvmv.station BETWEEN :kmfrom - 0.0001 AND :kmto + 0.0001)" @@ -63,9 +63,10 @@ * Query for a river's max km below a limit with all its q, main-v and tau values. */ private static final String SQL_SELECT_KMLOWER = // - "SELECT fvmv.station AS station, fvmv.q AS q, fvmv.main_channel AS vmain, fvmv.shear_stress AS tau" + " FROM flow_velocity_model_values fvmv" + "SELECT DISTINCT fvmv.station AS station, fvmv.q AS q, fvmv.main_channel AS vmain, fvmv.shear_stress AS tau" + + " FROM flow_velocity_model_values fvmv" + " INNER JOIN (SELECT MAX(fvmvi.station) AS kmmax" - + " FROM(discharge_zone dz INNER JOIN flow_velocity_model fvm ON dz.id = fvm.discharge_zone_id)" + + " FROM discharge_zone dz INNER JOIN flow_velocity_model fvm ON dz.id = fvm.discharge_zone_id" + " INNER JOIN flow_velocity_model_values fvmvi ON fvm.id = fvmvi.flow_velocity_model_id" + " WHERE (dz.river_id = :river_id) AND (fvmvi.station < :kmfrom - 0.0001)) finf ON fvmv.station = finf.kmmax" + " ORDER BY fvmv.q ASC"; @@ -74,9 +75,10 @@ * Query for a river's min km above a limit with all its q, main-v and tau values. */ private static final String SQL_SELECT_KMUPPER = // - "SELECT fvmv.station AS station, fvmv.q AS q, fvmv.main_channel AS vmain, fvmv.shear_stress AS tau" + " FROM flow_velocity_model_values fvmv" + "SELECT DISTINCT fvmv.station AS station, fvmv.q AS q, fvmv.main_channel AS vmain, fvmv.shear_stress AS tau" + + " FROM flow_velocity_model_values fvmv" + " INNER JOIN (SELECT MIN(fvmvi.station) AS kmmin" - + " FROM(discharge_zone dz INNER JOIN flow_velocity_model fvm ON dz.id = fvm.discharge_zone_id)" + + " FROM discharge_zone dz INNER JOIN flow_velocity_model fvm ON dz.id = fvm.discharge_zone_id" + " INNER JOIN flow_velocity_model_values fvmvi ON fvm.id = fvmvi.flow_velocity_model_id" + " WHERE (dz.river_id = :river_id) AND (fvmvi.station > :kmto + 0.0001)) fsup ON fvmv.station = fsup.kmmin" + " ORDER BY fvmv.q ASC";