I hay this table Day DayId Name --- ---- 1 sun 2 mon 3 tue 4 wed And this table Place PlaceId Loc DayId 1 1 1 1 1 2 1 2 1 2 1 3 3 1 2 3 1 4 i want to to return the days that are not used for each (PlaceId and LocId) so the result should be as follows PlaceId Loc DayId 1 1 3 1 1 4 1 2 2 1 2 3 1 2 4 2 1 1 2 1 2 2 1 4 3 1 1 3 1 3
select distinct Place.PlaceId, Place.Loc, Day.DayId from Place cross join Day left join Place AS X on Place.PlaceId = X.PlaceId and Place.Loc = X.Loc and Day.DayId = X.DayId where x.DayId is null
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)