I am a data-analyst, just diving into the SQL-depths. Forgive me if my problem stated here is not formulated clear, I am open for suggestions to improve my problem formulating skills!
So I have this table, but there is some double information in it (see --DATASET & --VALUES, PersonID = 2, RowNr = 1 & 2). I want to filter out rows that are double, so that the statement reads: Select only those rows for which CreationID in RowNr 1 != CreationID in RowNr 2, with rows grouped by PersonID and StartDate.
Here's my script with the desired result:
-- DATASET
CREATE TABLE Conditional (
PersonID int
, StartDate date
, CreationDate date
, RowNr int
);
-- VALUES
INSERT INTO Conditional (PersonID, StartDate, CreationDate, RowNr)
VALUES
('1', '20151201', '20151220', '1'),
('1', '20151201', '20151220', '2'),
('2', '20160303', '20160304', '1'),
('2', '20160303', '20160401', '2');
-- DESIRED RESULT
INSERT INTO Conditional (PersonID, StartDate, CreationDate, RowNr)
VALUES
('1', '20151201', '20151220', '1'),
('2', '20160303', '20160304', '1'),
('2', '20160303', '20160401', '2');