Error in 4.5 Expression must be a group key or aggregate



After upgrading to Couchbase 4.5 I have started getting this error “Expression must be a group key or aggregate (write.timestamp)”,“code”:4210}. I’m i doing something wrong here? here is my query

select max(timestamp) as lastDetect, count(timestamp) as detectCount from write where docType is not missing AND docType = 'DetectRecord' AND proximityUUID = $uuid AND major = $major AND minor = $minor AND timestamp BETWEEN $startTime AND $endTime ORDER BY timestamp desc limit 1;

Example document:

{ "id": "1234k", "docType": "DetectRecord", "proximityUUID": "12kdf", "major": "dkf", "minor": "ad", "timestamp": 1464954200000 }


Hi @mlblount45,

In your query, order by won’t make any difference you’re only getting a single document in the result.
timestamp isn’t projected to order by. Without grouping by timestamp. we won’t have the value to order by.