February 2, 2003 at 6:59 am
I have 2 tables.
Table 1 (VirtualDay) (5pm->4:59pm)
DayID, DateStart
Table 2 (RegisterLog)
DayID, StoreID, RegisterCount
in RegisterLog, I store the number of registers in a specific store. BUT I check to see if the number of registers has changed from the previous entry. I don't need to store a record if nothing has changed.
None of this is a problem.
What I want to get is a query which will return the latest record for ALL the stores but I only want 1 row returned for each store with the DAYID (when the change occured), the StoreID(of course), and the RegisterCount.
Is this something I can do in a stored proc, or should I just get the lot, and handle it in my application??
Help really appreciated
February 5, 2003 at 8:00 am
This was removed by the editor as SPAM
February 5, 2003 at 8:23 am
try this:
SELECT dt1.LastDayID, rl.StoreID, rl.RegisterCount
FROM RegisterLog rl
INNER JOIN
(
SELECT RegisterLog.StoreID, MAX(DayID) AS DayID
FROM RegisterLog
GROUP BY RegisterLog.StoreID
) AS dt1
ON rl.DayID = dt1.DayID
AND rl.StoreID = dt1.StoreID
ORDER BY rl.StoreID
February 7, 2003 at 12:26 am
Thanks so much.
I took this code, and made it work perfectly. Thanks for taking the time to reply.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply