Revision 47606 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.sqlite/org.gvsig.sqlite.provider/src/test/resources/org/gvsig/sqlite/dal/usecases/arena2/testOrderByExtraValue.sql
testOrderByExtraValue.sql | ||
---|---|---|
15 | 15 |
NULL AS "SIGNOS_INFLU_DROGAS", NULL AS "INFLU_PRES_INFRAC_COND", NULL AS "PRES_INFRAC_COND", NULL AS "PRES_INFRAC_SIN_LUCES", |
16 | 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 | 17 |
NULL AS "OTRA_INFRAC_COND", NULL AS "EXTRA", |
18 |
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",
|
|
18 |
CAST(strftime('%Y',"ARENA2_ACCIDENTES"."FECHA_ACCIDENTE") AS INTEGER) AS "ano",
|
|
19 |
"ARENA2_ACCIDENTES"."COD_PROVINCIA" AS "provincia", |
|
20 |
CASE WHEN (("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 1)) THEN ('Muerto') WHEN (("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 2)) THEN ('Grave') WHEN (((((("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 3) OR ("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 4)) OR ("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 5)) OR ("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 6)) OR ("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 7))) THEN ('Leve') WHEN (("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 8)) THEN ('Ileso') ELSE ('Se Desconoce') END AS "lesividad",
|
|
21 | 21 |
SUM(1) AS "Acc" |
22 |
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')))
|
|
22 |
FROM "ARENA2_CONDUCTORES" |
|
23 |
LEFT JOIN "ARENA2_ACCIDENTES" ON ( ("ARENA2_CONDUCTORES"."ID_ACCIDENTE") = ("ARENA2_ACCIDENTES"."ID_ACCIDENTE") )
|
|
24 |
LEFT JOIN "ARENA2_VEHICULOS" ON ( ("ARENA2_CONDUCTORES"."LID_VEHICULO") = ("ARENA2_VEHICULOS"."LID_VEHICULO") )
|
|
25 |
WHERE ((("ARENA2_ACCIDENTES"."TITULARIDAD_VIA" = 2) AND ((("ARENA2_VEHICULOS"."TIPO_VEHICULO" = 5) OR ("ARENA2_VEHICULOS"."TIPO_VEHICULO" = 6)) OR ("ARENA2_VEHICULOS"."TIPO_VEHICULO" = 7))) AND (("ARENA2_ACCIDENTES"."FECHA_ACCIDENTE" >= ('2019-01-01')) AND ("ARENA2_ACCIDENTES"."FECHA_ACCIDENTE" <= ('2019-12-31'))))
|
|
26 | 26 |
GROUP BY |
27 |
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
|
|
27 |
CAST(strftime('%Y',"ARENA2_ACCIDENTES"."FECHA_ACCIDENTE") AS INTEGER),
|
|
28 |
"ARENA2_ACCIDENTES"."COD_PROVINCIA", |
|
29 |
CASE WHEN (("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 1)) THEN ('Muerto') WHEN (("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 2)) THEN ('Grave') WHEN (((((("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 3) OR ("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 4)) OR ("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 5)) OR ("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 6)) OR ("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 7))) THEN ('Leve') WHEN (("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 8)) THEN ('Ileso') ELSE ('Se Desconoce') END
|
|
30 | 30 |
ORDER BY |
31 |
EXTRACT(YEAR FROM "PUBLIC"."ARENA2_ACCIDENTES"."FECHA_ACCIDENTE") ASC NULLS LAST,
|
|
32 |
"PUBLIC"."ARENA2_ACCIDENTES"."COD_PROVINCIA" ASC NULLS LAST,
|
|
31 |
CAST(strftime('%Y',"ARENA2_ACCIDENTES"."FECHA_ACCIDENTE") AS INTEGER) ASC NULLS LAST,
|
|
32 |
"ARENA2_ACCIDENTES"."COD_PROVINCIA" ASC NULLS LAST, |
|
33 | 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 | 34 |
LIMIT 15; |
35 | 35 |
|
36 | 36 |
-- Count |
37 | 37 |
SELECT COUNT(*) |
38 | 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",
|
|
39 |
FROM "ARENA2_CONDUCTORES" |
|
40 |
LEFT JOIN "ARENA2_ACCIDENTES" ON ( ("ARENA2_CONDUCTORES"."ID_ACCIDENTE") = ("ARENA2_ACCIDENTES"."ID_ACCIDENTE") )
|
|
41 |
LEFT JOIN "ARENA2_VEHICULOS" ON ( ("ARENA2_CONDUCTORES"."LID_VEHICULO") = ("ARENA2_VEHICULOS"."LID_VEHICULO") )
|
|
42 |
WHERE ((("ARENA2_ACCIDENTES"."TITULARIDAD_VIA" = 2) AND ((("ARENA2_VEHICULOS"."TIPO_VEHICULO" = 5) OR ("ARENA2_VEHICULOS"."TIPO_VEHICULO" = 6)) OR ("ARENA2_VEHICULOS"."TIPO_VEHICULO" = 7))) AND (("ARENA2_ACCIDENTES"."FECHA_ACCIDENTE" >= ('2019-01-01')) AND ("ARENA2_ACCIDENTES"."FECHA_ACCIDENTE" <= ('2019-12-31'))))
|
|
43 |
GROUP BY CAST(strftime('%Y',"ARENA2_ACCIDENTES"."FECHA_ACCIDENTE") AS INTEGER),
|
|
44 |
"ARENA2_ACCIDENTES"."COD_PROVINCIA", |
|
45 | 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')
|
|
46 |
WHEN (("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 1)) THEN ('Muerto') |
|
47 |
WHEN (("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 2)) THEN ('Grave') |
|
48 |
WHEN (((((("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 3) OR ("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 4)) OR ("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 5)) OR ("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 6)) OR ("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 7))) THEN ('Leve')
|
|
49 |
WHEN (("ARENA2_CONDUCTORES"."ASISTENCIA_SANITARIA" = 8)) THEN ('Ileso') |
|
50 | 50 |
ELSE ('Se Desconoce') |
51 | 51 |
END) AS _subquery_alias_; |
52 | 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_ ; |
Also available in: Unified diff