SQLTeam.com | Weblogs | Forums

Max Date with condition

Hey there,

Trying to get the max date by posting date column, movement type column 2, and material column 1.
Appreciate any help. TIA.

Max Date

do you want only 1 result returned? Please post your data as usable script and not an image

declare @rrman table(material int, mvt int, pstndate date, plnt char(5))

insert into @rrman
select 1025358, 601, '2019-01-10', 'HOU1' 

Thanks yosiasz...

I want all the result returned with max date sorted by material and movement (mvt) columns. Thanks!!!!

material	mvt	     pstngdate	  plnt
1025358		601	   1/10/2019	HOU1
1032608		101	   1/10/2019	NOR1
1040123		101	   1/10/2019	MID1
10510		601	   1/10/2019	CLU1
10540		601	   1/10/2019	WAC1
10565		601	   1/10/2019	WAC1

please follow the DDL,DML posted to provide usable data.

you can just do a simple

order by pstngdate, material, mvt

    , material
    , mvt	     
group by 
    , mvt