Hi
This is driving me nuts. I have a table which contains production plans. Several plans are held in the same table, each referenced by the 'Seq' field. What I am trying to determine is which records have been added to plan 17 which did not exist in plan 16. I've used a LEFT OUTER join but cant get it to work (0 rows returned although I've deleted a record from plan 16 which is otherwise identical to 17). The only thing I've done differently here to other queries I've written is create a join to the SAME TABLE.
Here's the query:
SELECT K1.* FROM KnitPlanWeek K1
LEFT OUTER JOIN KnitPlanWeek K2 ON K1.Style = K2.Style AND K1.Size = K2.Size AND K1.Year = K2.Year AND K1.Month = K2.Month AND K1.Week = K2.Week
WHERE K1.Seq = 17 AND K2.Seq = 16
AND ((K2.Style IS NULL)
OR (K2.Size IS NULL)
OR (K2.Year IS NULL)
OR (K2.Month IS NULL)
OR (K2.Week IS NULL))
I'm running this in SQL Server version 7 using Query Analyzer. Help!
Wayne
This is driving me nuts. I have a table which contains production plans. Several plans are held in the same table, each referenced by the 'Seq' field. What I am trying to determine is which records have been added to plan 17 which did not exist in plan 16. I've used a LEFT OUTER join but cant get it to work (0 rows returned although I've deleted a record from plan 16 which is otherwise identical to 17). The only thing I've done differently here to other queries I've written is create a join to the SAME TABLE.
Here's the query:
SELECT K1.* FROM KnitPlanWeek K1
LEFT OUTER JOIN KnitPlanWeek K2 ON K1.Style = K2.Style AND K1.Size = K2.Size AND K1.Year = K2.Year AND K1.Month = K2.Month AND K1.Week = K2.Week
WHERE K1.Seq = 17 AND K2.Seq = 16
AND ((K2.Style IS NULL)
OR (K2.Size IS NULL)
OR (K2.Year IS NULL)
OR (K2.Month IS NULL)
OR (K2.Week IS NULL))
I'm running this in SQL Server version 7 using Query Analyzer. Help!
Wayne