Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Query is close but not quite correct.
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
SQL Query is close but not quite correct.
Miscellaneous
Thread ID:
00408795
Message ID:
00408795
Views:
36
The following SQL query does nearly exactly what it should but I need to add one more thing to it and I am unsure how?
SELECT viewRequests.Course, 
       viewRequests.Priority, 
       viewRequests.ReqDate, 
       viewRequests.FirstName, 
       viewRequests.LastName, 
       viewRequests.Department, 
       viewRequests.Status, 
       Rates.Price, 
       viewRequests.PriorityID
FROM viewRequests 
       LEFT JOIN Rates ON viewRequests.CourseID = Rates.CourseID 
          AND viewRequests.DeliveryDate <= Rates.ExpiryDate 
          And viewRequests.DeliveryDate >= Rates.EffectiveDate
ORDER BY viewRequests.Course, viewRequests.LastName;
The tables it uses look like this:
viewRequests                  Rates
------------                  -----
ID                            ID
ReqDate                       VendorID
DeliveryDate                  CourseID
Course                        EffectiveDate
CourseID                      ExpiryDate
Priority                      Price
PriorityID
FirstName
LastName
Department
Status
The problem is that there can be two or more sets of rates from different vendors that have the same date range and I want to select for each request the lowest possible price.
Next
Reply
Map
View

Click here to load this message in the networking platform