• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Collapse

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "Access Query Help Needed"

Collapse

  • TimberWolf
    replied
    Originally posted by PRC1964 View Post
    This should do it:

    SELECT Table1.Date, Table1.EmployeeCode, Table1.Hours_On_TA_System, 0 AS Hours_On_WMS_System
    FROM Table1
    UNION
    Select Table2.Date, Table2.EmployeeCode, 0 As Hours_On_TA_System, Table2.Hours_On_WMS_System
    FROM Table2
    How's about summing by EmployeeCode (for all dates - danger!). It's been a while, just clearing away cobwebs...

    Code:
    SELECT tmptable.EmployeeCode, Sum(tmptable.TA_HOURS) AS SumOfTA_HOURS, Sum(tmptable.WMS_HOURS) AS SumOfWMS_HOURS
    FROM [SELECT  Table1.EmployeeCode as EmployeeCode, Table1.Hours_On_TA_System as TA_HOURS, 0 AS WMS_HOURS
          FROM Table1
          UNION ALL
          Select  Table2.EmployeeCode  as EmployeeCode, 0 As TA_HOURS, Table2.Hours_On_WMS_System as WMS_HOURS
          FROM Table2
       ]. AS tmptable
    GROUP BY tmptable.EmployeeCode;

    Leave a comment:


  • Sockpuppet
    replied
    Cheers guys.

    Help much appreciated.

    Leave a comment:


  • PRC1964
    replied
    This should do it:

    SELECT Table1.Date, Table1.EmployeeCode, Table1.Hours_On_TA_System, 0 AS Hours_On_WMS_System
    FROM Table1
    UNION
    Select Table2.Date, Table2.EmployeeCode, 0 As Hours_On_TA_System, Table2.Hours_On_WMS_System
    FROM Table2

    Leave a comment:


  • Spacecadet
    replied
    Like this?

    Code:
    Date   Employee Code Hours_On_WMS Hours_On_TA
    01/01 100001            2.5
    01/02 100002                                  8
    01/02 100003            6.5
    01/02 100004            3                    5.5
    In a proper system you need a Full outer join... but Access doesn't support this
    Have a google, there are ways of simulating a full outer join
    http://bytes.com/forum/thread190756.html

    Alternatively... create a numbers/dates table and use 2 left outer joins
    Last edited by Spacecadet; 1 October 2008, 08:19.

    Leave a comment:


  • TimberWolf
    replied
    Sounds like UNION ALL is what you're after.

    Leave a comment:


  • Sockpuppet
    started a topic Access Query Help Needed

    Access Query Help Needed

    I have 2 queries I am trying to combine here.

    I have 2 tables.

    Basically:

    Table1:
    Date
    EmployeeCode
    Hours_On_TA_System

    Table2:
    Date
    EmployeeCode
    Hours_On_WMS_System


    I'm trying to combine the two so that I get a list of:

    Date
    Employee Code
    Hours_On_WMS
    Hours_On_TA


    The problem with doing a join is that employees may appear in either table1, table2 or both.

    With joins I can either show those in table1 matching to those in table 2. Or those in table 2 and the matching records from table 1.

    There may be people who are in table 1 and not table 2 but also those that are in table 2 but not 1 at the same time.

    Any ideas...I seem to remember something about Union queries but I can't see if this is what I need.

    Cheers
    Sockpuppet
Working...
X