[FWTools] Max() or limit in OGR SQL

David Fawcett david.fawcett at gmail.com
Thu Apr 19 21:53:23 EDT 2007


I am using an OGR connection to a shapefile in a MapServer map file in order
to use SQL to get the last record in the shape.

I have tried to order it by an ID column descending and then use limit 1 or
rownum = 1, these didn't work.

I have also tried WHERE ID = MAX(ID), but I get an error message that
indicates that MAX is being interpreted as a string and that the comparison
is illegal.

msOGRFileOpen(): OGR error. ExecuteSQL(SELECT FID, * FROM bryantrip WHERE
FID = MAX(FID) ORDER BY timeLoc desc) failed. SQL: Attempt to compare
numeric field `FID' to non-numeric value `MAX' is illegal.

Can anyone suggest OGR SQL to get the last row of the shape?

Thanks,

David.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/fwtools/attachments/20070419/b373502c/attachment.html


More information about the FWTools mailing list