Hi Expert,
if there is no value change for status continuously and without any new value in between then
expected output
('2022-03-31 12:52:49','Newtwo', '6-1')
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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 18:00:57','Newtwo','segmenthee')
Hi Expert,
if there is no value change for status continuously and without any new value in between then
expected output
('2022-03-31 12:52:49','Newtwo', '6-1')
suggestion please
here is overall requirement and expected ... first two conditions are working only last row result condition required
('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')
('2022-03-28 15:58:40','Newtwo', '6-1'),
('2022-03-28 12:52:49','Newtwo', '4-1')
('2022-03-31 12:52:49','Newtwo', '6-1'),
('2022-04-01 12:52:49','Newtwo', '6-1'),
('2022-04-28 15:58:40','Newtwo', '6-1'),
('2022-04-29 12:52:49','Newtwo', '6-1'),
('2022-04-30 12:52:49','Newtwo', '6-1'),
('2022-05-01 12:52:49','Newtwo', '6-1'),
('2022-05-29 12:52:49','Newtwo', '6-1'),
('2022-05-31 12:52:49','Newtwo', '6-1'),
('2022-06-01 12:52:49','Newtwo', '6-1'),
('2022-06-02 12:52:49','Newtwo', '6-1')
Expected output
('2022-01-04 19:00:57','Newone','segmentone')
('2022-04-04 19:00:57','Newtwo','segmenfour')
('2022-03-28 15:58:40','Newtwo', '6-1')
the condition for last pair is if value of same status is repeated on next day and so on then it should take minimum date or may be you send me the query for only this let me try from my end
,
('2022-03-28 12:52:49','Newtwo', '4-1'),
('2022-03-31 12:52:49','Newtwo', '6-1'),
('2022-04-01 12:52:49','Newtwo', '6-1'),
('2022-04-28 15:58:40','Newtwo', '6-1'),
('2022-04-29 12:52:49','Newtwo', '6-1'),
('2022-04-30 12:52:49','Newtwo', '6-1'),
('2022-05-01 12:52:49','Newtwo', '6-1'),
('2022-05-29 12:52:49','Newtwo', '6-1'),
('2022-05-31 12:52:49','Newtwo', '6-1'),
('2022-06-01 12:52:49','Newtwo', '6-1'),
('2022-06-02 12:52:49','Newtwo', '6-1')
HI Expert,
you can neglect the first condition,
('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')
('2022-03-28 15:58:40','Newtwo', '6-1'),
('2022-03-28 12:52:49','Newtwo', '4-1')
('2022-03-31 12:52:49','Newtwo', '6-1'),
('2022-04-01 12:52:49','Newtwo', '6-1'),
('2022-04-28 15:58:40','Newtwo', '6-1'),
('2022-04-29 12:52:49','Newtwo', '6-1'),
('2022-04-30 12:52:49','Newtwo', '6-1'),
('2022-05-01 12:52:49','Newtwo', '6-1'),
('2022-05-29 12:52:49','Newtwo', '6-1'),
('2022-05-31 12:52:49','Newtwo', '6-1'),
('2022-06-01 12:52:49','Newtwo', '6-1'),
('2022-06-02 12:52:49','Newtwo', '6-1')
expected output
Expected output
('2022-04-04 19:00:57','Newtwo','segmenfour')
('2022-03-28 15:58:40','Newtwo', '6-1')