Solved

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

Posted on 2008-06-25
3
189 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

758 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

22 Experts available now in Live!

Get 1:1 Help Now