Advertisement

05.07.2008 at 11:39PM PDT, ID: 23385218
[x]
Attachment Details

Advanced Conditional Query Access

Asked by DreamAwake in Access Coding/Macros, Databases Miscellaneous, SQL Query Syntax

Tags: Microsoft, Access, 2003, Access/Visual Basic

I have attached a screen shot of my database schema.

This is my scenario;

There are 3 different situations when it comes to searching a quote.

1. You have a job with 0 quotes.
2. You have a job with say 3 quotes, but none have been awarded.
3. You have a job with 3 Quotes, 1 or 2 have been awarded.

I want to have a query which lists all quotes but if the job has awarded 1 of the quotes I don't want to see the others. But I still need to see new jobs without quotes. I understand outer joins are needed but honestly i've spent hours on this and need some major assistance.

I have the following so far which is showing all quotes but is displaying un-awarded quotes when a quote has been awarded.Start Free Trial
1:
2:
3:
4:
SELECT tblContract.MNW, tblContract.Location, tblContract.Status, tblCompany.CompanyName, tblQuote.awarded
FROM (tblContract LEFT JOIN tblQuote ON tblContract.ContractID = tblQuote.ContractID) LEFT JOIN tblCompany ON tblQuote.CompanyID = tblCompany.CompanyID
GROUP BY tblContract.MNW, tblContract.Location, tblContract.Status, tblCompany.CompanyName, tblQuote.awarded
HAVING (((tblContract.MNW)="mw000669") AND ((tblQuote.awarded)=1));
Attachments:
 
Access Database Schema
Access Database Schema
 
[+][-]05.07.2008 at 11:51PM PDT, ID: 21522761

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Coding/Macros, Databases Miscellaneous, SQL Query Syntax
Tags: Microsoft, Access, 2003, Access/Visual Basic
Sign Up Now!
Solution Provided By: Thomasian
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628