Sum Two Fields On Left Join?

Chris2404

Registered User.
Local time
Today, 15:20
Joined
Jul 10, 2013
Messages
13
Hi,

I currently have two tables each containing information that I need to complete a query, however the results of suming this information is incorrect.

Below is the structure of the table, one contains more fileds than the other however the joins are on the Date and the Name fields. I have added a few dummy results to show the format

Table 1
"Date" "Name" "Times Logged In"
10/01/2013 Chris 1
11/01/2013 James 3

Table 2
"Date" "Region" "Manager Name" "Name" "Times Logged Out"
10/01/2013 Scotland Cindy Chris 1
11/01/2013 Wales Robert James 2

Query Fields
"Data" "Region" "Name" "SUM Times Logged In" "SUM Times Logged Out"


I can see what the issue is, if someone hasnt logged out there would be no entry in the table so the result query would show "Times Logged In" as X and a blank value at "Times Logged Out." However if there is a value at "Times Logged Out", "Times Logged In" is displayed again and causes the SUM calculations to be incorrect.

Hopefully that makes sense, how do I overcome this issue though? I can do two spereate queries on the tables to produce results for Times Logged In and Times Logged Out but cant seem to create one query to display both these results in one table.

What I want is IF the date in Table 2 = Date in Table 1 AND IF Name in Table 2 = Name in Table 1 THEN take the value from Logged In and place that in a column and the value from Logged Out and place that in a column.

Thanks for the help
 
Last edited:
Can you post some sample data all the way through? Post data that is in table 1 and table 2 and then what data should be returned in your query based on the sample data. Be sure to include samples of all cases.
 
I can't fully understand what is going on, seeing the SQL. Would help.

Brian
 

Users who are viewing this thread

Back
Top Bottom