0
User
========
uid
name
Data
=========
distance
timeSpend
isShow
uid (FK)
我想获得以下citeria
1) in a specific timeSpend Range
2) group by the uid (Only select the longest Distance)
3) only isShow
尝试下面的查询,但没有运气的距离的顺序列表(DESC)。感谢您的帮助
SELECT User.name, Data.distance, Data.timeSpend
FROM FROM User,Data
WHERE id IN (
SELECT MAX(distance) FROM Data GROUP BY uid WHERE isShow = true
)
AND User.uid = Data.uid
ORDER BY Data.distance DESC
感谢您的帮助值 – user782104