Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    149

    Unanswered: Help with a query

    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, 7

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Did 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

  3. #3
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    149
    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')

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    149
    Never mind. I think I have a solution. Thanks for your time Pat.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •