Solved

How do I create a select statement with an outerjoin on access queries?

Posted on 2008-06-25
3
190 Views
Last Modified: 2013-11-27
I have an asp page that queries an access query.  I now need to join the query results from one query with those from another query in the same db. My question is how do I outer join vwResults8.Team on vwResults2.Team.  My existing select statement is:

SELECT Team,  SUM(EffectiveRevenueReal) AS Rev From vwResults2 GROUP BY Team Order By SUM(EffectiveRevenueReal) DESC

I'd like to select all fields from vwResults8 and join on vwResults8.Team
0
Comment
Question by:hologosesh
  • 2
3 Comments
 
LVL 32

Expert Comment

by:Daniel Wilson
ID: 21866257
I'm writing this as though you want ALL records from vwResults2 and matching from vwResults8.  If the other way around, change LEFT to RIGHT.  If all from both, change LEFT to FULL
SELECT Team,  SUM(EffectiveRevenueReal) AS Rev,

  vwResults8.*

From vwResults2 LEFT Outer Join vwResults8 on vwResults2.Team = vwResults8.Team

GROUP BY Team Order By SUM(EffectiveRevenueReal) DESC

Open in new window

0
 
LVL 32

Accepted Solution

by:
Daniel Wilson earned 125 total points
ID: 21866284
Hold on ... messed up some of the GROUP BY stuff:

Replace the Field1 - FieldN with real field names
SELECT Team,  SUM(EffectiveRevenueReal) AS Rev,

  vwResults8.*

From vwResults2 LEFT Outer Join vwResults8 on vwResults2.Team = vwResults8.Team

GROUP BY vwResults2.Team ,

vwResults8.Field1, vwResults8.Field2, ... vwResults8.FieldN

Order By SUM(EffectiveRevenueReal) DESC

Open in new window

0
 

Author Closing Comment

by:hologosesh
ID: 31470564
Works great, thanks.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now