Ver Mensaje Individual
  #3 (permalink)  
Antiguo 19/09/2011, 08:12
Pelirr
 
Fecha de Ingreso: diciembre-2008
Mensajes: 233
Antigüedad: 15 años, 4 meses
Puntos: 1
Respuesta: consultas query en jasperreport, listado strings

Hola, al final he dado con la solución.

Por un lado, la consulta queda como sigue:

Cita:
select
companies.company as airline,
(select
count(*)
from `aodb`.`arrivalflight` a
where a.iataCompanyCode = airline and a.scheduledTime >= $P{fechaInformeDesde} and a.scheduledTime < $P{fechaInformeHasta}
) as numArr,
(select
count(*)
from `aodb`.`departureflight` b
where b.iataCompanyCode = airline and b.scheduledTime >= $P{fechaInformeDesde} and b.scheduledTime < $P{fechaInformeHasta}
) as numDep,
(
(select
count(*)
from `aodb`.`arrivalflight` a
where a.iataCompanyCode = airline and a.scheduledTime >= $P{fechaInformeDesde} and a.scheduledTime < $P{fechaInformeHasta}
)
+
(select
count(*)
from `aodb`.`departureflight` b
where b.iataCompanyCode = 'airline' and b.scheduledTime >= $P{fechaInformeDesde} and b.scheduledTime < $P{fechaInformeHasta}
)
) as totalMov

from
(
select distinct
e.iataCompanyCode as company
from `aodb`.`arrivalFlight` e where e.iataCompanyCode in ("$P!{listadoAerolineas}")
union
(select distinct
f.iataCompanyCode as company
from `aodb`.`departureflight` f where f.iataCompanyCode in ("$P!{listadoAerolineas}")
)
) as companies;
y por otro lado, hay que definir el parámetro listadoAerolineas como un string en el ireport, y aquí viene lo importante, ponerle un valor inicial por defecto (yo le he puesto ""). De éste modo no hay problema y todo va bien.
Además, el listado que debe metérsele como string no debe contener las comillas inicial y final, es decir, debería ser algo así:

listadoAerolineas = IB", "AEM", "OCC

Espero que le sirva a alguien, y gracias por todo.

Un saludo