I want to select max date from may layer by below query in my Web GIS but I cannot.

(SELECT MAX( GregorianDate ) FROM DrillingProgress WHERE Crew = 'c-Chabock')
  • Could you add a sample from your table?
    – Martin
    Commented Aug 29, 2013 at 7:56

1 Answer 1


Definition queries are used to get a subset of a layer for visualization purposes. Your query only gets the last date, but not the corresponding record.

So I guess what you want to do is to get the (chronological) last record of a table to visualize it in a layer. If that is right, the definition query would be something like this (you need a nested query to determine the max date, and then you filter your table for records corresponding to that date):

select * 
from DrillingProgress
where GregorianDate = (SELECT MAX( GregorianDate ) FROM DrillingProgress WHERE Crew = 'c-Chabock') 
and Crew = 'c-Chabock'

Not the answer you're looking for? Browse other questions tagged or ask your own question.