svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.h2spatial / org.gvsig.h2spatial.h2gis132 / org.gvsig.h2spatial.h2gis132.provider / src / test / resources / org / gvsig / fmap / dal / store / h2 / usecases / arena2 / testOrderByExtraValue.sql @ 46507
History | View | Annotate | Download (7.6 KB)
1 | 46104 | omartinez | |
---|---|---|---|
2 | -- ResultSetForSetProvider SQL
|
||
3 | |||
4 | -- Select
|
||
5 | 46105 | omartinez | SELECT
|
6 | 46505 | fdiaz | NULL AS "LID_CONDUCTOR", NULL AS "ID_ACCIDENTE", NULL AS "LID_VEHICULO", NULL AS "ID_VEHICULO", NULL AS "POSIBLE_RESPONSABLE", NULL AS "FECHA_NACIMIENTO", |
7 | NULL AS "SEXO", NULL AS "NACIONALIDAD", NULL AS "PAIS_RESIDENCIA", NULL AS "PROVINCIA_RESIDENCIA", NULL AS "MUNICIPIO_RESIDENCIA", NULL AS "ASISTENCIA_SANITARIA", |
||
8 | NULL AS "INFLU_FACT_ATENCION", NULL AS "FACTORES_ATENCION", NULL AS "INFLU_PRES_ERROR", NULL AS "PRESUNTOS_ERRORES", NULL AS "CARACT_PERMISO", |
||
9 | NULL AS "CLASE_PERMISO", NULL AS "FECHA_PERMISO", NULL AS "MOTIVO_DESPLAZAMIENTO", NULL AS "DESPLAZAMIENTO_PREVISTO", NULL AS "ACC_SEG_CINTURON", |
||
10 | NULL AS "ACC_SEG_CASCO", NULL AS "ACC_SEG_BRAZOS", NULL AS "ACC_SEG_ESPALDA", NULL AS "ACC_SEG_TORSO", NULL AS "ACC_SEG_MANOS", NULL AS "ACC_SEG_PIERNAS", |
||
11 | NULL AS "ACC_SEG_PIES", NULL AS "ACC_SEG_PRENDA_REF", NULL AS "INFLU_ALCOHOL", NULL AS "PRUEBA_ALCOHOLEMIA", NULL AS "TASA_ALCOHOLEMIA1", |
||
12 | NULL AS "TASA_ALCOHOLEMIA2", NULL AS "PRUEBA_ALC_SANGRE", NULL AS "SIGNOS_INFLU_ALCOHOL", NULL AS "INFLU_DROGAS", NULL AS "PRUEBA_DROGAS", NULL AS "AMP", |
||
13 | NULL AS "CONFIRMADO_AMP", NULL AS "BDZ", NULL AS "CONFIRMADO_BDZ", NULL AS "COC", NULL AS "CONFIRMADO_COC", NULL AS "THC", NULL AS "CONFIRMADO_THC", |
||
14 | NULL AS "METH", NULL AS "CONFIRMADO_METH", NULL AS "OPI", NULL AS "CONFIRMADO_OPI", NULL AS "OTRAS", NULL AS "CONFIRMADO_OTRAS", |
||
15 | NULL AS "SIGNOS_INFLU_DROGAS", NULL AS "INFLU_PRES_INFRAC_COND", NULL AS "PRES_INFRAC_COND", NULL AS "PRES_INFRAC_SIN_LUCES", |
||
16 | NULL AS "PRES_INFRAC_SIN_TRIANGULO", NULL AS "INFLU_PRES_INFRAC_VEL", NULL AS "PRES_INFRAC_VEL_COND", NULL AS "INFLU_OTRA_INFRAC", |
||
17 | NULL AS "OTRA_INFRAC_COND", NULL AS "EXTRA", |
||
18 | 46507 | jjdelcerro | EXTRACT(YEAR FROM "PUBLIC"."ARENA2_ACCIDENTES"."FECHA_ACCIDENTE") AS "ano", |
19 | "PUBLIC"."ARENA2_ACCIDENTES"."COD_PROVINCIA" AS "provincia", |
||
20 | CASE WHEN (("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 1)) THEN ('Muerto') WHEN (("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 2)) THEN ('Grave') WHEN (((((("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 3) OR ("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 4)) OR ("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 5)) OR ("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 6)) OR ("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 7))) THEN ('Leve') WHEN (("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 8)) THEN ('Ileso') ELSE ('Se Desconoce') END AS "lesividad", |
||
21 | 46505 | fdiaz | SUM(1) AS "Acc" |
22 | 46507 | jjdelcerro | FROM "PUBLIC"."ARENA2_CONDUCTORES" |
23 | LEFT JOIN "PUBLIC"."ARENA2_ACCIDENTES" ON ( ("PUBLIC"."ARENA2_CONDUCTORES"."ID_ACCIDENTE") = ("PUBLIC"."ARENA2_ACCIDENTES"."ID_ACCIDENTE") ) |
||
24 | LEFT JOIN "PUBLIC"."ARENA2_VEHICULOS" ON ( ("PUBLIC"."ARENA2_CONDUCTORES"."LID_VEHICULO") = ("PUBLIC"."ARENA2_VEHICULOS"."LID_VEHICULO") ) |
||
25 | WHERE ((("PUBLIC"."ARENA2_ACCIDENTES"."TITULARIDAD_VIA" = 2) AND ((("PUBLIC"."ARENA2_VEHICULOS"."TIPO_VEHICULO" = 5) OR ("PUBLIC"."ARENA2_VEHICULOS"."TIPO_VEHICULO" = 6)) OR ("PUBLIC"."ARENA2_VEHICULOS"."TIPO_VEHICULO" = 7))) AND (("PUBLIC"."ARENA2_ACCIDENTES"."FECHA_ACCIDENTE" >= DATE '2019-01-01') AND ("PUBLIC"."ARENA2_ACCIDENTES"."FECHA_ACCIDENTE" <= DATE '2019-12-31'))) |
||
26 | 46105 | omartinez | GROUP BY |
27 | 46507 | jjdelcerro | EXTRACT(YEAR FROM "PUBLIC"."ARENA2_ACCIDENTES"."FECHA_ACCIDENTE"), |
28 | "PUBLIC"."ARENA2_ACCIDENTES"."COD_PROVINCIA", |
||
29 | CASE WHEN (("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 1)) THEN ('Muerto') WHEN (("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 2)) THEN ('Grave') WHEN (((((("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 3) OR ("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 4)) OR ("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 5)) OR ("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 6)) OR ("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 7))) THEN ('Leve') WHEN (("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 8)) THEN ('Ileso') ELSE ('Se Desconoce') END |
||
30 | 46505 | fdiaz | ORDER BY |
31 | 46507 | jjdelcerro | EXTRACT(YEAR FROM "PUBLIC"."ARENA2_ACCIDENTES"."FECHA_ACCIDENTE") ASC NULLS LAST, |
32 | "PUBLIC"."ARENA2_ACCIDENTES"."COD_PROVINCIA" ASC NULLS LAST, |
||
33 | CASE WHEN (("ASISTENCIA_SANITARIA" = 1)) THEN ('Muerto') WHEN (("ASISTENCIA_SANITARIA" = 2)) THEN ('Grave') WHEN (((((("ASISTENCIA_SANITARIA" = 3) OR ("ASISTENCIA_SANITARIA" = 4)) OR ("ASISTENCIA_SANITARIA" = 5)) OR ("ASISTENCIA_SANITARIA" = 6)) OR ("ASISTENCIA_SANITARIA" = 7))) THEN ('Leve') WHEN (("ASISTENCIA_SANITARIA" = 8)) THEN ('Ileso') ELSE ('Se Desconoce') END ASC NULLS LAST |
||
34 | 46105 | omartinez | LIMIT 15;
|
35 | 46104 | omartinez | |
36 | -- Count
|
||
37 | 46507 | jjdelcerro | SELECT COUNT(*) |
38 | FROM ( SELECT SUM(1) AS "Acc" |
||
39 | FROM "PUBLIC"."ARENA2_CONDUCTORES" |
||
40 | LEFT JOIN "PUBLIC"."ARENA2_ACCIDENTES" ON ( ("PUBLIC"."ARENA2_CONDUCTORES"."ID_ACCIDENTE") = ("PUBLIC"."ARENA2_ACCIDENTES"."ID_ACCIDENTE") ) |
||
41 | LEFT JOIN "PUBLIC"."ARENA2_VEHICULOS" ON ( ("PUBLIC"."ARENA2_CONDUCTORES"."LID_VEHICULO") = ("PUBLIC"."ARENA2_VEHICULOS"."LID_VEHICULO") ) |
||
42 | WHERE ((("PUBLIC"."ARENA2_ACCIDENTES"."TITULARIDAD_VIA" = 2) AND ((("PUBLIC"."ARENA2_VEHICULOS"."TIPO_VEHICULO" = 5) OR ("PUBLIC"."ARENA2_VEHICULOS"."TIPO_VEHICULO" = 6)) OR ("PUBLIC"."ARENA2_VEHICULOS"."TIPO_VEHICULO" = 7))) AND (("PUBLIC"."ARENA2_ACCIDENTES"."FECHA_ACCIDENTE" >= DATE '2019-01-01') AND ("PUBLIC"."ARENA2_ACCIDENTES"."FECHA_ACCIDENTE" <= DATE '2019-12-31'))) |
||
43 | GROUP BY EXTRACT(YEAR FROM "PUBLIC"."ARENA2_ACCIDENTES"."FECHA_ACCIDENTE"), |
||
44 | "PUBLIC"."ARENA2_ACCIDENTES"."COD_PROVINCIA", |
||
45 | CASE
|
||
46 | WHEN (("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 1)) THEN ('Muerto') |
||
47 | WHEN (("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 2)) THEN ('Grave') |
||
48 | WHEN (((((("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 3) OR ("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 4)) OR ("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 5)) OR ("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 6)) OR ("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 7))) THEN ('Leve') |
||
49 | WHEN (("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 8)) THEN ('Ileso') |
||
50 | ELSE ('Se Desconoce') |
||
51 | END) AS _subquery_alias_ ; |
||
52 | |||
53 | |||
54 | -- SELECT COUNT(*) FROM ( SELECT SUM(1) AS "Acc" FROM "PUBLIC"."ARENA2_CONDUCTORES" LEFT JOIN "PUBLIC"."ARENA2_ACCIDENTES" ON ( ("PUBLIC"."ARENA2_CONDUCTORES"."ID_ACCIDENTE") = ("PUBLIC"."ARENA2_ACCIDENTES"."ID_ACCIDENTE") ) LEFT JOIN "PUBLIC"."ARENA2_VEHICULOS" ON ( ("PUBLIC"."ARENA2_CONDUCTORES"."LID_VEHICULO") = ("PUBLIC"."ARENA2_VEHICULOS"."LID_VEHICULO") ) WHERE ((("PUBLIC"."ARENA2_ACCIDENTES"."TITULARIDAD_VIA" = 2) AND ((("PUBLIC"."ARENA2_VEHICULOS"."TIPO_VEHICULO" = 5) OR ("PUBLIC"."ARENA2_VEHICULOS"."TIPO_VEHICULO" = 6)) OR ("PUBLIC"."ARENA2_VEHICULOS"."TIPO_VEHICULO" = 7))) AND (("PUBLIC"."ARENA2_ACCIDENTES"."FECHA_ACCIDENTE" >= DATE '2019-01-01') AND ("PUBLIC"."ARENA2_ACCIDENTES"."FECHA_ACCIDENTE" <= DATE '2019-12-31'))) GROUP BY EXTRACT(YEAR FROM "PUBLIC"."ARENA2_ACCIDENTES"."FECHA_ACCIDENTE"), "PUBLIC"."ARENA2_ACCIDENTES"."COD_PROVINCIA", CASE WHEN (("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 1)) THEN ('Muerto') WHEN (("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 2)) THEN ('Grave') WHEN (((((("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 3) OR ("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 4)) OR ("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 5)) OR ("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 6)) OR ("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 7))) THEN ('Leve') WHEN (("PUBLIC"."ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 8)) THEN ('Ileso') ELSE ('Se Desconoce') END) as _subquery_alias_ ; |