56,675
社区成员
发帖
与我相关
我的任务
分享
select id, Fid, theMinValue, theMaxValue from t_value
inner join(select Fid as maxValueFid, (case when theMaxValue is null then null else max(theMaxValue) end) as maxValue from t_value )
on Fid = maxValueFid and theMaxValue = maxValue
select id, Fid, theMinValue, theMaxValue from t_value
inner join(select Fid as maxValueFid, (case when theMaxValue is null then null else max(theMaxValue) end) as maxValue from t_value )
on Fid = maxValueFid and (theMaxValue = maxValue or theMaxValue is null)
这样就能查出想要的结果。但是有没有更好的查询方式呢?有idea的求不吝赐教!