When value is same for the status then

  • Hi Expert,

    there is condition when value is same for the status then it should take min date and if the value is change for the status then max date

    create table test

    (newdate datetime,status varchar(10), value varchar(10))

    insert into test

     

    values

    ('2022-01-04 18:00:57','Newone','segmentone'),('2022-01-04 19:00:57','Newone','segmentone'),

    ('2022-04-04 18:00:57','Newtwo','segmenthee'),('2022-04-04 19:00:57','Newtwo','segmenfour')

     

     

    expected output

    ('2022-01-04 18:00:57','Newone','segmentone')

    ('2022-04-04 19:00:57','Newtwo','segmentfour')

  • suggestion please

  • I suggest that you don't open multiple threads for the same topic.  Responses here: https://www.sqlservercentral.com/forums/topic/max-date-order-by-status

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply