Just use a correlated subquery:
SELECT *
FROM data
WHERE TCH_Traffic = (SELECT MAX(d2.TCH_Traffic)
FROM data as d2
WHERE d2.object = data.object
);
MS Access' default Jet/ACE SQL Engine can process a subquery in a WHERE
condition using IN
clause. However, subquery must return one column value. Consider the following adjustment:
SELECT *
FROM data WHERE (object) IN
( SELECT object
FROM data
GROUP BY object
HAVING TCH_Traffic = MAX(TCH_Traffic)
);
However, you can simply use a derived table with INNER JOIN
and avoid WHERE
clause subquery. Also, same derived table query can be saved as a stored query object in MS Access and explicitly referenced in join clause:
SELECT *
FROM data
INNER JOIN
( SELECT object, MAX(TCH_Traffic) As maxTraffic
FROM data
GROUP BY object
) As dT
ON data.object = dT.object
AND data.TCH_Traffic = dt.maxTraffic
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.