Hi I was trying to do a Sub Query and Comparison Report
For Example, I have a Table of Teams with Color AND Name in a Single Table. A person can be on more than one Team and Multiple Team Colors can exist in the table.
CREATE TABLE [TEAMS](
[Color] [nvarchar](10) NULL,
[Name] [nvarchar](10) NULL
);
INSERT INTO TEAMS (Color,Name) VALUES
(N'Red',N'Austin'),
(N'Blue',N'Austin'),
(N'Red',N'James'),
(N'Yellow',N'Melissa'),
(N'Blue',N'Brandon');
I was trying to get a query to help identify the differences between two Teams like who is different between the Red and Blue Team and get something like this.
I was hoping to do a Full Join on the Name with NULLs in Table A and NULLs in Table B to Find the Differences but because its the same Table No NULLS are Occurring.
The Query I was doing for my comparison is this.
Select a.Color, a.Name, b.Color, b.Name from TEAMS a
FULL JOIN TEAMS b on a.Name = b.Name
WHERE a.Color = 'Red' AND b.Color = 'Blue';
Removing the WHERE CLAUSE is also Revealing that Team Color is Comparing to itself (Red Team A to Red Team B, etc...) and the team I'm not interested in (Yellow) is also being used in the Query and eating Resources.
This seems possible with Temporary Tables if just Red Team was in Table A and just Blue Team was in Table B but is there a Way to Do this with some form of Sub Query?