[Qgis-developer] problem with GROUP BY in `Execute SQL` Processing

Even Rouault even.rouault at spatialys.com
Tue Jan 20 01:49:38 PST 2015


Le mardi 20 janvier 2015 10:40:05, Jürgen E. Fischer a écrit :
> Hi Matteo,
> 
> On Tue, 20. Jan 2015 at 09:47:50 +0100, Matteo Ghetta wrote:
> > yes, the column is ID.
> 
> Meaning that ID is the only column in au?  Did you try to use ID instead of
> *?
> 
> > On Fri, 16. Jan 2015 at 10:48:16 +0100, Matteo Ghetta wrote:
> > > GDAL execution console output
> > > 
> > > ERROR 1: SQL Expression Parsing Error: syntax error
> > 
> > Maybe GROUP BY function is not supported in Processing yet?
> 
> Well, I don't really know processing, but it looks more like an error from
> OGR.
> 
> Anyway, my observation was just about the SQL.  You usually don't use *
> with GROUP BY, because you can only select columns that appear in the
> GROUP BY and can only use other in aggregate functions (min, max, sum...).
> 
> Maybe you can use: select distinct id from au

Just seeing this topic. OGR SQL does not support GROUP BY (as non-documented 
in http://gdal.org/ogr_sql.html ;-)). You have to use the SQLite dialect for 
that ( http://gdal.org/ogr_sql_sqlite.html ).

e.g. :
ogrinfo poly.shp -sql "select * from poly group by eas_id" -dialect sqlite

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the Qgis-developer mailing list