SELECT h11, HA11
FROM florin.h11
WHERE (3>d1 AND 3<d2) OR (3>d1 AND 3=d2 AND id=MAX(id))
UNION (3=d1 AND 3<d2 AND id=MIN(id));
这是我的表格结构截图:
答案 0 :(得分:1)
我认为你想做的事情是这样的:
SELECT h11, HA11
FROM florin.h11
WHERE (3>d1 AND 3<d2)
OR (3>d1 AND 3=d2 AND id = (SELECT MAX(t2.id)
FROM florin.h11 AS t2))
OR (3=d1 AND 3<d2 AND id = (SELECT MIN(t3.id)
FROM florin.h11 AS t3));
答案 1 :(得分:0)
首先是错误的事情
如果florin是表,那么只写“从florin选择h11,HA11”,不要写列名。
第二个错误的事情是
所以,像
一样点火查询select h11, HA11
from florin
where (3 > d1 and 3 < d2) or (3 > d1 and 3 = d2 and id = MAX(id))
union
select h11, HA11
from florin
where (3 = d1 and 3 < d2 and id = MIN(id))
这里的查询可能没有返回所需的结果,但这是我想象你想要这种类型的查询。