Paul,
if you add a DEBUG 2 to your LAYER definition, you'll also get some
debugging info as to what is happening inside mapserver's postgis
driver, along with the query that is actually sent by mapserver to
postgis (as mapserver adds some spatial filtering to account for the
current map view).
Perfect answer Thomas!
After adding DEBUG 2 in my layer, I see that the actual select statement
is
select label,encode(ST_AsBinary(ST_Force_2D(the_geom),'NDR'),'hex') as
geom,site_id from (select (count(*)/((date '8-31-2013'- date
'4-1-2013')+1)::numeric=0.98) as list,