如何选择最多具有多个条件的数据
SELECT * FROM [TEMP_TBL],其中“ FLDR_NUM” =(从[TEMP_TBL]选择MAX(FLDR_NUM))和“ DNLD_DT” =(从[TEMP_TBL)选择MAX(DNLD_DT)] >>
[如何选择具有多个最大条件的数据SELECT * FROM [TEMP_TBL],其中“ FLDR_NUM” =(SELECT MAX(FLDR_NUM)来自[TEMP_TBL])和“ DNLD_DT” =(SELECT MAX(DNLD_DT)来自[TEMP_TBL)
您可以使用cte
重用您的max()
值。
with cte(maxflr) as (
select max(fldr_num) as maxflr from TEMP_TBL
)select * from TEMP_TBL
cross apply cte
where "FLDR_NUM" = cte.maxflr and "DNLD_DT" = cte.maxflr