I currently have one large data set that has the following columns and rows as an example.
Latest Name Code Date Number
Y abc def 9/10/2017 123
N abc def 10/10/2014 123
N abc def 08/08/2008 123
I need to change the output so that it reads as follows:
Latest Name Code Date Number Latest Name Code Number
Y abc def 9/10/2017 123 N abc def 10/10/2014 123
Y abc def 9/10/2017 123 N abc def 08/08/2008 123
I have thought through the issue and I think I need to split the table into 2 smaller tables, one with Y as Latest and one with N as Latest then use an inner join to match the results? can anyone help me with this please? I have tried the following:
CREATE Table Latest AS
SELECT *
FROM [Original Table]
WHERE Latest = 'Y'
CREATE Table Latest AS
SELECT *
FROM [Original Table]
WHERE Latest = 'N'
However I'm getting an error when I tried to run the queries - Incorrect Syntax near SELECT, expecting ID
When it comes to the join I intend to join these using the code column. Can anyone help please?
CREATE TABLEsyntax on SQL-Server.