LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Subquery after Left Join

All:

I have a Personnel table and a Attendance table. I want to join the two,
retrieving all employees but only specific attendance. The following query
works without error, but only gives me employees with matching attendance
records.

SELECT p.p_empno, p.p_fname, p.p_lname, a.a_date, a.a_reason, a.a_comments
FROM hrpersnl p LEFT JOIN
hattran a ON p.p_empno = a.a_empno
WHERE (p.p_active="A") and (a.a_date Between {d '2006-01-01'} And {d
'2006-01-14'})

To get a true left join, I used the following concept in Access, which
worked perfectly. I simply replace the joined table with a subquery and
moved the "where" clause. When I try it in MS Query, I get a "Syntax Error"
message.

SELECT p.p_empno, p.p_fname, p.p_lname, a.a_date, a.a_reason, a.a_comments
FROM hrpersnl p LEFT JOIN
(SELECT * FROM hattran a
WHERE (a.a_date Between {d '2006-01-01'} And {d '2006-01-14'})) a
ON p.p_empno = a.a_empno
WHERE p.p_active="A"


Is there a way I can make this concept work?

Thanks!

greg

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2003, Microsoft Query - reference to subquery alias Finnman Excel Discussion (Misc queries) 1 December 2nd 08 11:21 AM
Join tables like inner join in Access ryanp Excel Discussion (Misc queries) 2 July 18th 08 03:35 PM
LEFT JOIN sql query Michael Malinsky[_2_] Excel Programming 2 August 28th 05 08:09 PM
Subquery dc Excel Worksheet Functions 7 June 3rd 05 01:36 PM
ADO Recordset Problem -- Left Join ExcelMan Excel Programming 5 January 24th 05 08:53 AM


All times are GMT +1. The time now is 01:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"