First of all, I just realized that I posted the following question in the SQL Server Group, but probably should have posted it here instead. Don't mean to "over-step" boundaries, but I really need some help, so hopefully someone will come to the rescue...
I have the following SQL statement, however there may be multiple records for a TrackingNumber. The TrackingNumber and the DeliveryDate (which has a time stamp in it) make up the composite primary key. I need to look at the most recent record for each TrackingNumber and then check the criteria in my where clause, but I'm not sure how to do this.
PLEASE HELP!
SELECT
a.TrackingNumber, a.InboundDate, a.InboundUser, a.DeliveryDate, a.Recipient, a.Signature, [Enter Date as mm/dd/yyyy] AS Inbound
FROM dbo_vw_Stor_Del_2 AS a
WHERE (((a.Recipient) Is Null) AND ((a.Signature) Is Null) AND ((Format([a.InboundDate],'mm/dd/yyyy'))=[Enter Date as mm/dd/yyyy])) OR (((a.Signature) Is Null) AND ((Format([a.InboundDate],'mm/dd/yyyy'))=[Enter Date as mm/dd/yyyy]) AND ((UCase([Recipient])) Not In ("DRIVER RELEASE","HARD COPY SIGNATURE")));
TIA!
I have the following SQL statement, however there may be multiple records for a TrackingNumber. The TrackingNumber and the DeliveryDate (which has a time stamp in it) make up the composite primary key. I need to look at the most recent record for each TrackingNumber and then check the criteria in my where clause, but I'm not sure how to do this.
PLEASE HELP!
SELECT
a.TrackingNumber, a.InboundDate, a.InboundUser, a.DeliveryDate, a.Recipient, a.Signature, [Enter Date as mm/dd/yyyy] AS Inbound
FROM dbo_vw_Stor_Del_2 AS a
WHERE (((a.Recipient) Is Null) AND ((a.Signature) Is Null) AND ((Format([a.InboundDate],'mm/dd/yyyy'))=[Enter Date as mm/dd/yyyy])) OR (((a.Signature) Is Null) AND ((Format([a.InboundDate],'mm/dd/yyyy'))=[Enter Date as mm/dd/yyyy]) AND ((UCase([Recipient])) Not In ("DRIVER RELEASE","HARD COPY SIGNATURE")));
TIA!