我有这些选择
SELECT ah.IDA, ah.HFR1
FROM AHIS ah
WHERE
ah.HFR1 > 0
AND
(ah.HFR1 >= $DATE_FROM AND ah.HFR1 < $DATE_TO)
AND ( ah.TIME_MILIS < $DATE_TO)
AND not exists (select 1
from AHIS ah2
where -(ah.HFR1) = ah2.HFR1 AND ah2.TIME_MILIS < $DATE_TO
)
AND
($FID = (SELECT a.IDFA FROM `ITEM` a WHERE a.ID = ah.IDA LIMIT 1 ))
GROUP BY ah.IDA
SELECT ah.IDA, ah.HFR2
FROM AHIS ah
WHERE
ah.HFR2 > 0
AND
(ah.HFR2 >= $DATE_FROM AND ah.HFR2 < $DATE_TO)
AND ( ah.TIME_MILIS < $DATE_TO)
AND not exists (select 1
from AHIS ah2
where -(ah.HFR2) = ah2.HFR2 AND ah2.TIME_MILIS < $DATE_TO
)
AND
($FID = (SELECT a.IDFA FROM `ITEM` a WHERE a.ID = ah.IDA LIMIT 1 ))
GROUP BY ah.IDA
如您所见,HFR1,HFR2,HFR3等所有变化都是如此。 有什么方法可以把它放在一个查询中吗?