sql server mseq:
The following query contains a order header table and a
modification table that keeps track of all changes made
to the order header table. The modification table stores
the date and time a mofication was made. Also, the
modifcation table can have numerous records with the same
order number for the same date.
The following query returns the order numbers when they
were sent to the 'YARD' (which is 41)
Lets say Order Number 4345 was sent to the Yard 2 times
on 11-20-2003 11:00 and once at 11-20-03 14:00. I need
only 1 record to show- the one that occured later in the
day.
Can someone help me structure this? Do I need to use a
Stored Procedure? I have never written a Stored
Procedure!
Thanks
SELECT to_ordnum, mo_date, dbo.DDTORD.to_trak2id,
to_totdue, to_broknum
FROM DDTORD INNER JOIN DXMOD ON DDTORD.to_ordnum =
DXMOD.mo_recid ANDDDTORD.to_ordnum = DXMOD.mo_recid
WHERE (mo_table = 'ddtord') AND (mo_newval = 41)