Bonjour,

J'ai une erreur avec cette requête à cause du group by et je n'arrive pas à le résoudre:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
select coo_trk_id, coo_time, coo_length, min(ST_Distance(
  geography(st_transform(coo_2d,4326)),
  ST_GeographyFromText('POINT(3.075206 50.369314)'))) as distance
from coordinates, track
WHERE coo_trk_id=trk_id AND trk_status IN (0,4) AND trk_veh_id=1
and st_contains(GeomFromText('POLYGON((2.79271955988 50.1891338198, 3.35769244012 50.1891338198, 
    3.35769244012 50.5494941802, 2.79271955988 50.5494941802, 2.79271955988 50.1891338198))',4326), coo_2d)
group by coo_trk_id
order by distance
En faite, je souhaiterais récupérer la distance minimale par trajet (coo_trk_id) ainsi que coo_time et coo_length. L'erreur est la suivante:

ERROR: column "coordinates.coo_time" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: select coo_trk_id, coo_time, coo_length, min(ST_Distance(
Si quelqu'un à une piste, merci de me l'indiquer.