J
jason
Need guidance - I am really struggling here. I have two queries which track
two criteria for a particular yacht:
- Price Changes
- Market Changes
I need to somehow combine them or link them to allow me to work out what
exactly has changed for a particular boat(s) and then formulate
an email to the user.
These are the possible outcomes for a particular boat:
A. A boat has a price reduction and a change in market status
B. A boat has a price reduction but NO market status change
C. A boat has NO price reduction but has a market status change
D. A boat has NO price reduction and NO market Status Change.
Here are my two queries that are currently seperate from each other:
1. -------------------------------
MARKET STATUS QUERY (Tracks Market Status Changes for a boat)
-------------------------------
PARAMETERS LID Long, pDate DateTime;
SELECT [tblListings].[Name], [tblModel].[Model] AS Model,
[tblListings].[Size_ID] AS Size_ID, Max([audMarketStatus].[AudDate]) AS
AudDate, [audMarketStatus].[AudType], [audMarketStatus].[AudUser],
[audMarketStatus].[AudIP], [audMarketStatus].[ListingsID],
[audMarketStatus].[Old_Status_ID], tblMarketStatus_2.Market_Status AS
OLDSTATUS, [audMarketStatus].[New_Status_ID],
tblMarketStatus_3.Market_Status AS NEWSTATUS
FROM tblMarketStatus AS tblMarketStatus_3 INNER JOIN (tblMarketStatus AS
tblMarketStatus_2 INNER JOIN (tblModel INNER JOIN (tblMarketStatus INNER
JOIN (audMarketStatus INNER JOIN tblListings ON
[audMarketStatus].[ListingsID]=[tblListings].[ListingsID]) ON
[tblMarketStatus].[MarketStatusID]=[tblListings].[Status_ID]) ON
[tblModel].[ModelID]=[tblListings].[Model_ID]) ON
tblMarketStatus_2.MarketStatusID=[audMarketStatus].[Old_Status_ID]) ON
tblMarketStatus_3.MarketStatusID=[audMarketStatus].[New_Status_ID]
GROUP BY [tblListings].[Name], [tblModel].[Model], [tblListings].[Size_ID],
[audMarketStatus].[AudType], [audMarketStatus].[AudUser],
[audMarketStatus].[AudIP], [audMarketStatus].[ListingsID],
[audMarketStatus].[Old_Status_ID], tblMarketStatus_2.Market_Status,
[audMarketStatus].[New_Status_ID], tblMarketStatus_3.Market_Status, [LID],
[pDate]
HAVING ((([LID]) Is Null) AND (([pDate]) Is Null)) OR
(((audMarketStatus.ListingsID)=[LID]) AND (([pDate]) Is Null)) OR
(((Max(audMarketStatus.AudDate))=[pDate]) AND (([LID]) Is Null)) OR
(((Max(audMarketStatus.AudDate))=[pDate]) AND
((audMarketStatus.ListingsID)=[LID]));
1. -------------------------------
PRICE CHANGES(Tracks Market Status Changes for a boat)
-------------------------------
PARAMETERS LID Long;
SELECT tblListingsPriceChanges.*, [tblListings].[ListingsID],
[tblListingsPriceChanges].[PriceChangeInsertionDate] AS
PriceChangeInsertionDate
FROM tblListings INNER JOIN tblListingsPriceChanges ON
[tblListings].[ListingsID]=[tblListingsPriceChanges].[ListingsID]
WHERE ((([LID]) Is Null)) Or ((([tblListings].[ListingsID])=[LID]))
ORDER BY [ChangeDate] DESC;
Many thanks for any help you can offer me.
Regards
Jason
two criteria for a particular yacht:
- Price Changes
- Market Changes
I need to somehow combine them or link them to allow me to work out what
exactly has changed for a particular boat(s) and then formulate
an email to the user.
These are the possible outcomes for a particular boat:
A. A boat has a price reduction and a change in market status
B. A boat has a price reduction but NO market status change
C. A boat has NO price reduction but has a market status change
D. A boat has NO price reduction and NO market Status Change.
Here are my two queries that are currently seperate from each other:
1. -------------------------------
MARKET STATUS QUERY (Tracks Market Status Changes for a boat)
-------------------------------
PARAMETERS LID Long, pDate DateTime;
SELECT [tblListings].[Name], [tblModel].[Model] AS Model,
[tblListings].[Size_ID] AS Size_ID, Max([audMarketStatus].[AudDate]) AS
AudDate, [audMarketStatus].[AudType], [audMarketStatus].[AudUser],
[audMarketStatus].[AudIP], [audMarketStatus].[ListingsID],
[audMarketStatus].[Old_Status_ID], tblMarketStatus_2.Market_Status AS
OLDSTATUS, [audMarketStatus].[New_Status_ID],
tblMarketStatus_3.Market_Status AS NEWSTATUS
FROM tblMarketStatus AS tblMarketStatus_3 INNER JOIN (tblMarketStatus AS
tblMarketStatus_2 INNER JOIN (tblModel INNER JOIN (tblMarketStatus INNER
JOIN (audMarketStatus INNER JOIN tblListings ON
[audMarketStatus].[ListingsID]=[tblListings].[ListingsID]) ON
[tblMarketStatus].[MarketStatusID]=[tblListings].[Status_ID]) ON
[tblModel].[ModelID]=[tblListings].[Model_ID]) ON
tblMarketStatus_2.MarketStatusID=[audMarketStatus].[Old_Status_ID]) ON
tblMarketStatus_3.MarketStatusID=[audMarketStatus].[New_Status_ID]
GROUP BY [tblListings].[Name], [tblModel].[Model], [tblListings].[Size_ID],
[audMarketStatus].[AudType], [audMarketStatus].[AudUser],
[audMarketStatus].[AudIP], [audMarketStatus].[ListingsID],
[audMarketStatus].[Old_Status_ID], tblMarketStatus_2.Market_Status,
[audMarketStatus].[New_Status_ID], tblMarketStatus_3.Market_Status, [LID],
[pDate]
HAVING ((([LID]) Is Null) AND (([pDate]) Is Null)) OR
(((audMarketStatus.ListingsID)=[LID]) AND (([pDate]) Is Null)) OR
(((Max(audMarketStatus.AudDate))=[pDate]) AND (([LID]) Is Null)) OR
(((Max(audMarketStatus.AudDate))=[pDate]) AND
((audMarketStatus.ListingsID)=[LID]));
1. -------------------------------
PRICE CHANGES(Tracks Market Status Changes for a boat)
-------------------------------
PARAMETERS LID Long;
SELECT tblListingsPriceChanges.*, [tblListings].[ListingsID],
[tblListingsPriceChanges].[PriceChangeInsertionDate] AS
PriceChangeInsertionDate
FROM tblListings INNER JOIN tblListingsPriceChanges ON
[tblListings].[ListingsID]=[tblListingsPriceChanges].[ListingsID]
WHERE ((([LID]) Is Null)) Or ((([tblListings].[ListingsID])=[LID]))
ORDER BY [ChangeDate] DESC;
Many thanks for any help you can offer me.
Regards
Jason