Guys-
Any help with this query is greatly appreciated... 
DECLARE @.input TABLE
 (NodeId VARCHAR(10),
  IsChecked CHAR(1))
DECLARE @.Actual TABLE
 (AndSetId INT,
  NodeId VARCHAR(10),
  IsChecked CHAR(1))
INSERT INTO @.Input VALUES ('a', 'T')
INSERT INTO @.Input VALUES ('b', 'T')
INSERT INTO @.Input VALUES ('c', 'F')
INSERT INTO @.Input VALUES ('d', 'F')
INSERT INTO @.Input VALUES ('e', 'T')
INSERT INTO @.Actual VALUES (1, 'a', 'T')
INSERT INTO @.Actual VALUES (1, 'b', 'T')
INSERT INTO @.Actual VALUES (1, 'c', 'F')
INSERT INTO @.Actual VALUES (2, 'c', 'F')
INSERT INTO @.Actual VALUES (2, 'd', 'F')
INSERT INTO @.Actual VALUES (3, 'd', 'F')
INSERT INTO @.Actual VALUES (5, 'd', 'F')
INSERT INTO @.Actual VALUES (5, 'e', 'F')
INSERT INTO @.Actual VALUES (6, 'f', 'F')
INSERT INTO @.Actual VALUES (7, 'g', 'F')
-- We should get back 1, 2, 3, 4.  We should not get back 5, 6, 7Did your instructor include the rules (the logic) behind this, or only give you the two inputs and the output that they expected?  Have you recently covered anything like this in class?
-PatP|||Pat-
My apologies for not elaborating enough, what I was looking for.  
Get all AndSetIds from @.Actual where 
if NodeId is present in @.input then the isChecked should match.
          eg:  AndSetId 1
                   It has 3 records.  And the records match with the records 
                   in Input.
                 So 1 should be returned.
                 Where as let us look at AndSet 5.
                   It has NodeId 'e' as 'F' where as the input has 'e' as 'T'
                  So 5 should not be returned.
INSERT INTO @.Input VALUES ('a', 'T')
INSERT INTO @.Input VALUES ('b', 'T')
INSERT INTO @.Input VALUES ('c', 'F')
INSERT INTO @.Input VALUES ('d', 'F')
INSERT INTO @.Input VALUES ('e', 'T')
INSERT INTO @.Actual VALUES (1, 'a', 'T')
INSERT INTO @.Actual VALUES (1, 'b', 'T')
INSERT INTO @.Actual VALUES (1, 'c', 'F')
INSERT INTO @.Actual VALUES (2, 'c', 'F')
INSERT INTO @.Actual VALUES (2, 'd', 'F')
INSERT INTO @.Actual VALUES (3, 'd', 'F')
INSERT INTO @.Actual VALUES (5, 'd', 'F')
INSERT INTO @.Actual VALUES (5, 'e', 'F')
INSERT INTO @.Actual VALUES (6, 'f', 'F')
INSERT INTO @.Actual VALUES (7, 'g', 'F')|||Never mind.  I think I have a solution.  Thanks for your time Pat.sql
Subscribe to:
Post Comments (Atom)
 
No comments:
Post a Comment