Loading ...
Sorry, an error occurred while loading the content.
 

Query Questions

Expand Messages
  • Richard Rogers
    Here is my query: SELECT TestREIT.dbo.gltrxdet.seg2_code, dbo.tblUtilityControl.AcctNo FROM TestREIT.dbo.gltrx INNER JOIN TestREIT.dbo.gltrxdet ON
    Message 1 of 2 , Mar 10, 2005
      Message
      Here is my query:
       
      SELECT     TestREIT.dbo.gltrxdet.seg2_code, dbo.tblUtilityControl.AcctNo
      FROM         TestREIT.dbo.gltrx INNER JOIN
                            TestREIT.dbo.gltrxdet ON TestREIT.dbo.gltrx.journal_ctrl_num = TestREIT.dbo.gltrxdet.journal_ctrl_num RIGHT OUTER JOIN
                            dbo.tblUtilityControl ON TestREIT.dbo.gltrxdet.seg3_code = dbo.tblUtilityControl.AcctNo
      GROUP BY TestREIT.dbo.gltrxdet.seg2_code, dbo.tblUtilityControl.AcctNo
      HAVING      (TestREIT.dbo.gltrxdet.seg2_code = '1656')
       
      tblUtilityControl has three rows however my result set contains only two rows.  This query returns the three rows expected in MS Access. 
      What do I need to do differently for SQL Server to get three rows of output?
      NOTICE: This e-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure, or distribution is prohibited. The contents of this e-mail are confidential. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. Please virus check all attachments to prevent widespread contamination and corruption of files and operating systems!
    • Troy
      Since you re grouping by TestREIT.dbo.gltrxdet.seg2_code and dbo.tblUtilityControl.AcctNo , make sure you don t have duplicates in the three records on
      Message 2 of 2 , Mar 11, 2005
        Since you're grouping by "TestREIT.dbo.gltrxdet.seg2_code" and
        "dbo.tblUtilityControl.AcctNo", make sure you don't have duplicates in
        the three records on those fields. Your query 'groups', but doesn't
        'count'. If you want all records returned, remove the GROUP BY
        clause.

        --- In SQLQueriesNoCode@yahoogroups.com, Richard Rogers <rrogers@t...>
        wrote:
        > Here is my query:
        >
        > SELECT TestREIT.dbo.gltrxdet.seg2_code, dbo.
        tblUtilityControl.AcctNo
        > FROM TestREIT.dbo.gltrx INNER JOIN
        > TestREIT.dbo.gltrxdet ON
        > TestREIT.dbo.gltrx.journal_ctrl_num =
        TestREIT.dbo.gltrxdet.journal_ctrl_num
        > RIGHT OUTER JOIN
        > dbo.tblUtilityControl ON
        > TestREIT.dbo.gltrxdet.seg3_code = dbo.tblUtilityControl.AcctNo
        > GROUP BY TestREIT.dbo.gltrxdet.seg2_code, dbo.tb
        lUtilityControl.AcctNo
        > HAVING (TestREIT.dbo.gltrxdet.seg2_code = '1656')
        >
        > tblUtilityControl has three rows however my result set contains
        only two
        > rows. This query returns the three rows expected in MS Access.
        > What do I need to do differently for SQL Server to get three rows of
        output?
        >
        > NOTICE: This e-mail message is for the sole use of the intended
        recipient(s) and may contain confidential and privileged information.
        Any unauthorized review, use, disclosure, or distribution is
        prohibited. The contents of this e-mail are confidential. If you are
        not the intended recipient, please contact the sender by reply e-mail
        and destroy all copies of the original message. Please virus check all
        attachments to prevent widespread contamination and corruption of
        files and operating systems!
      Your message has been successfully submitted and would be delivered to recipients shortly.