rotation."startdate" AND (
output."startdate">=rotation."startdate" AND
output."startdate"=rotation."startdate"
)
)
OR
(
rotation."startdate"=rotation."enddate"
)
)
LEFT JOIN weps('stir_energy') AS stir2 ON
stir2."runid"=rotation."runid" AND
stir2."cropnumber"=rotation."cropwithharvestnumber" AND
stir2."lastharvest"=1
WHERE
rotation."runid"=$P{RUN_ID}
GROUP BY
rotation."cropwithharvestnumber",
rotation."crop",
rotation."startdate",
rotation."enddate"
ORDER BY
rotation."cropwithharvestnumber"]]>