+ Reply to Thread
Results 1 to 5 of 5

Combining 2 queries with Distinct Fields

  1. #1
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Combining 2 queries with Distinct Fields

    I am currently using 2 queries to get recordsets from a database as follows:

    Please Login or Register  to view this content.
    Which outputs the following:
    FORCE_Completions Name Username
    5 Kyle Kyle123
    5 James James123

    ICOMS_Completions Name Username
    10 Kyle Kyle123
    5 Kevin Kevin123


    I would like to combine these into a single query with the following:

    FORCE_Completions ICOMS_Completions Name Username
    5 10 Kyle Kyle123
    5 0 James James123
    0 5 Kevin Kevin123







    However a given user may appear in either query or both and I'm unsure how best to join the recordsets to get the output I would like

    Although I've posted this in the Access forum, I'm using SQL Server (2005) as I think this a conceptual issue rather than a specific one to access.

    Any help is much appreciated
    Last edited by Kyle123; 02-23-2012 at 09:36 AM.

  2. #2
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Combining 2 queries with Distinct Fields

    Can you not do a SUM query based on a subquery that UNIONs those two queries?
    Good luck.

  3. #3
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Combining 2 queries with Distinct Fields

    yes, I was overthinking it

    The following is the SQL I'm using:
    Please Login or Register  to view this content.

  4. #4
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: Combining 2 queries with Distinct Fields

    Quote Originally Posted by Kyle123 View Post
    yes, I was overthinking it
    Luckily, I'm too simple to ever have that problem.

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Combining 2 queries with Distinct Fields

    hehe that's usually what I say!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1