Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Left Join problem

Status
Not open for further replies.

88solmyr

Programmer
Jul 25, 2006
2
US
Here's my testing query

SELECT BillableTime
FROM TimeAcctDetail
WHERE u.EmployeeId=17 and Tacode not like '9%'
and Tadate between '04/01/2006' and '04/30/2006'

return 0 record.

SELECT Firstname,lastname,SUM(BillableTime) as BillTime
FROM UserDetail u
LEFT join TimeAcctDetail t
ON u.employeeId=T.EmployeeId WHERE u.EmployeeId=17 and Tacode not like '9%'
and Tadate between '04/01/2006' and '04/30/2006'
GROUP BY u.EmployeeID,u.Lastname,u.Firstname

This query return 0 record. I expect it to return a record with null value for BillTime.

How can I get the result I want? thanks for you help
 
Where are Tacode and Tadate coming from ?
Hopefully not from TimeAcctDetail as it would defeat the OUTER join purpose ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Code:
select u.Firstname
     , u.lastname
     , sum(t.BillableTime) as BillTime
  from UserDetail u 
left outer
  join TimeAcctDetail t
    on t.EmployeeId = u.employeeId
   and t.Tacode not like '9%'
   and t.Tadate between '2006-04-01'
                    and '2006-04-30'
 where u.EmployeeId = 17 
group 
    by u.EmployeeID
     , u.Lastname
     , u.Firstname

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top