选择多个条件MAX

问题描述 投票:-1回答:1

如何选择最多具有多个条件的数据

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)

jquery sql ssis ssms
1个回答
0
投票

您可以使用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
© www.soinside.com 2019 - 2024. All rights reserved.