Hi All
Just stuck again with combining a 3 queries. I have tried to combine them but I don't get the correct value at the end.
What the query is suppost to do:
I have a date which all 3 of these fields have to be signed off by (Attn, IP, SLA). If any of these miss the date that it needs to be signed off by then it should show on this query. This should also happen if any one of the 3 are null and the due date has passed.
tblTracking.PerfDate is the due date
These are the fields which have to be signed off.
qrybAttn.Date
qrybIP.Date
qrybSLA.Date
I had to use an int option as the dates have time on them too.
Here are the 3 queries I am trying to combine:
1.
SELECT tblTracking.PortfolioCode, tblTracking.PerfDate, IIf(IsNull([qrybAttn].[Date]),Null,CDate(Int([qrybAttn].[Date]))) AS AttnD_Date, Count(*) AS CountOfPerfDate, tblTracking.ProductType
FROM tblTracking LEFT JOIN qrybAttn ON tblTracking.TrackingID = qrybAttn.TrackingID
WHERE (((Int(Nz([qrybAttn].[Date],Date())))>[tblTracking].[PerfDate]) AND ((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date())) OR (((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date()) AND ((qrybAttn.Date) Is Null))
GROUP BY tblTracking.PortfolioCode, tblTracking.PerfDate, IIf(IsNull([qrybAttn].[Date]),Null,CDate(Int([qrybAttn].[Date]))), tblTracking.ProductType
ORDER BY tblTracking.PortfolioCode;
2.
SELECT tblTracking.PortfolioCode, tblTracking.PerfDate, IIf(IsNull([qrybIP].[Date]),Null,CDate(Int([qrybIP].[Date]))) AS IPD_Date, Count(*) AS CountOfPerfDate, tblTracking.ProductType
FROM tblTracking LEFT JOIN qrybIP ON tblTracking.TrackingID = qrybIP.TrackingID
WHERE (((Int(Nz([qrybIP].[Date],Date())))>[tblTracking].[PerfDate]) AND ((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date())) OR (((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date()) AND ((qrybIP.Date) Is Null))
GROUP BY tblTracking.PortfolioCode, tblTracking.PerfDate, IIf(IsNull([qrybIP].[Date]),Null,CDate(Int([qrybIP].[Date]))), tblTracking.ProductType
ORDER BY tblTracking.PortfolioCode;
3.
SELECT tblTracking.PortfolioCode, tblTracking.PerfDate, IIf(IsNull([qrybSLA].[Date]),Null,CDate(Int([qrybSLA].[Date]))) AS SLAD_Date, Count(*) AS CountOfPerfDate, tblTracking.ProductType
FROM tblTracking LEFT JOIN qrybSLA ON tblTracking.TrackingID = qrybSLA.TrackingID
WHERE (((Int(Nz([qrybSLA].[Date],Date())))>[tblTracking].[PerfDate]) AND ((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date())) OR (((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date()) AND ((qrybSLA.Date) Is Null))
GROUP BY tblTracking.PortfolioCode, tblTracking.PerfDate, IIf(IsNull([qrybSLA].[Date]),Null,CDate(Int([qrybSLA].[Date]))), tblTracking.ProductType
ORDER BY tblTracking.PortfolioCode;
This is what I have done to combine them, but as I said I am still not getting the correct value.
SELECT tblTracking.PortfolioCode, tblTracking.PerfDate, IIf(IsNull([qrybAttn].[Date]),Null,CDate(Int([qrybAttn].[Date]))) AS D_Date1, IIf(IsNull([qrybIP].[Date]),Null,CDate(Int([qrybIP].[Date]))) AS _Date2, IIf(IsNull([qrybSLA].[Date]),Null,CDate(Int([qrybSLA].[Date]))) AS D_Date3, Count(*) AS CountOfPerfDate, tblTracking.ProductType
FROM ((tblTracking LEFT JOIN qrybAttn ON tblTracking.TrackingID = qrybAttn.TrackingID) LEFT JOIN qrybIP ON tblTracking.TrackingID = qrybIP.TrackingID) LEFT JOIN qrybSLA ON tblTracking.TrackingID = qrybSLA.TrackingID
WHERE (((Int(Nz([qrybAttn].[Date],Date())))>[tblTracking].[PerfDate]) AND ((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date())) OR (((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date()) AND ((qrybAttn.Date) Is Null))
AND (((Int(Nz([qrybIP].[Date],Date())))>[tblTracking].[PerfDate]) AND ((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date())) OR (((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date()) AND ((qrybIP.Date) Is Null))
AND(((Int(Nz([qrybSLA].[Date],Date())))>[tblTracking].[PerfDate]) AND ((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date())) OR (((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date()) AND ((qrybSLA.Date) Is Null))
GROUP BY tblTracking.PortfolioCode, tblTracking.PerfDate, IIf(IsNull([qrybAttn].[Date]),Null,CDate(Int([qrybAttn].[Date]))), IIf(IsNull([qrybIP].[Date]),Null,CDate(Int([qrybIP].[Date]))), IIf(IsNull([qrybSLA].[Date]),Null,CDate(Int([qrybSLA].[Date]))), tblTracking.ProductType
ORDER BY tblTracking.PortfolioCode;
If you would like to have a look at thread number 1330813 to see how I got this far with another query.
Any help with this will be great.
Thanks in advance.
Regards
Mark
Just stuck again with combining a 3 queries. I have tried to combine them but I don't get the correct value at the end.
What the query is suppost to do:
I have a date which all 3 of these fields have to be signed off by (Attn, IP, SLA). If any of these miss the date that it needs to be signed off by then it should show on this query. This should also happen if any one of the 3 are null and the due date has passed.
tblTracking.PerfDate is the due date
These are the fields which have to be signed off.
qrybAttn.Date
qrybIP.Date
qrybSLA.Date
I had to use an int option as the dates have time on them too.
Here are the 3 queries I am trying to combine:
1.
SELECT tblTracking.PortfolioCode, tblTracking.PerfDate, IIf(IsNull([qrybAttn].[Date]),Null,CDate(Int([qrybAttn].[Date]))) AS AttnD_Date, Count(*) AS CountOfPerfDate, tblTracking.ProductType
FROM tblTracking LEFT JOIN qrybAttn ON tblTracking.TrackingID = qrybAttn.TrackingID
WHERE (((Int(Nz([qrybAttn].[Date],Date())))>[tblTracking].[PerfDate]) AND ((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date())) OR (((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date()) AND ((qrybAttn.Date) Is Null))
GROUP BY tblTracking.PortfolioCode, tblTracking.PerfDate, IIf(IsNull([qrybAttn].[Date]),Null,CDate(Int([qrybAttn].[Date]))), tblTracking.ProductType
ORDER BY tblTracking.PortfolioCode;
2.
SELECT tblTracking.PortfolioCode, tblTracking.PerfDate, IIf(IsNull([qrybIP].[Date]),Null,CDate(Int([qrybIP].[Date]))) AS IPD_Date, Count(*) AS CountOfPerfDate, tblTracking.ProductType
FROM tblTracking LEFT JOIN qrybIP ON tblTracking.TrackingID = qrybIP.TrackingID
WHERE (((Int(Nz([qrybIP].[Date],Date())))>[tblTracking].[PerfDate]) AND ((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date())) OR (((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date()) AND ((qrybIP.Date) Is Null))
GROUP BY tblTracking.PortfolioCode, tblTracking.PerfDate, IIf(IsNull([qrybIP].[Date]),Null,CDate(Int([qrybIP].[Date]))), tblTracking.ProductType
ORDER BY tblTracking.PortfolioCode;
3.
SELECT tblTracking.PortfolioCode, tblTracking.PerfDate, IIf(IsNull([qrybSLA].[Date]),Null,CDate(Int([qrybSLA].[Date]))) AS SLAD_Date, Count(*) AS CountOfPerfDate, tblTracking.ProductType
FROM tblTracking LEFT JOIN qrybSLA ON tblTracking.TrackingID = qrybSLA.TrackingID
WHERE (((Int(Nz([qrybSLA].[Date],Date())))>[tblTracking].[PerfDate]) AND ((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date())) OR (((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date()) AND ((qrybSLA.Date) Is Null))
GROUP BY tblTracking.PortfolioCode, tblTracking.PerfDate, IIf(IsNull([qrybSLA].[Date]),Null,CDate(Int([qrybSLA].[Date]))), tblTracking.ProductType
ORDER BY tblTracking.PortfolioCode;
This is what I have done to combine them, but as I said I am still not getting the correct value.
SELECT tblTracking.PortfolioCode, tblTracking.PerfDate, IIf(IsNull([qrybAttn].[Date]),Null,CDate(Int([qrybAttn].[Date]))) AS D_Date1, IIf(IsNull([qrybIP].[Date]),Null,CDate(Int([qrybIP].[Date]))) AS _Date2, IIf(IsNull([qrybSLA].[Date]),Null,CDate(Int([qrybSLA].[Date]))) AS D_Date3, Count(*) AS CountOfPerfDate, tblTracking.ProductType
FROM ((tblTracking LEFT JOIN qrybAttn ON tblTracking.TrackingID = qrybAttn.TrackingID) LEFT JOIN qrybIP ON tblTracking.TrackingID = qrybIP.TrackingID) LEFT JOIN qrybSLA ON tblTracking.TrackingID = qrybSLA.TrackingID
WHERE (((Int(Nz([qrybAttn].[Date],Date())))>[tblTracking].[PerfDate]) AND ((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date())) OR (((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date()) AND ((qrybAttn.Date) Is Null))
AND (((Int(Nz([qrybIP].[Date],Date())))>[tblTracking].[PerfDate]) AND ((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date())) OR (((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date()) AND ((qrybIP.Date) Is Null))
AND(((Int(Nz([qrybSLA].[Date],Date())))>[tblTracking].[PerfDate]) AND ((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date())) OR (((tblTracking.PortfolioCode) Not In ("630541","630542")) AND ((tblTracking.PerfDate)<Date()) AND ((qrybSLA.Date) Is Null))
GROUP BY tblTracking.PortfolioCode, tblTracking.PerfDate, IIf(IsNull([qrybAttn].[Date]),Null,CDate(Int([qrybAttn].[Date]))), IIf(IsNull([qrybIP].[Date]),Null,CDate(Int([qrybIP].[Date]))), IIf(IsNull([qrybSLA].[Date]),Null,CDate(Int([qrybSLA].[Date]))), tblTracking.ProductType
ORDER BY tblTracking.PortfolioCode;
If you would like to have a look at thread number 1330813 to see how I got this far with another query.
Any help with this will be great.
Thanks in advance.
Regards
Mark