VB.NET How to select the earliest and latest record of a set of rows based on timestamp and ID Sql server
Posted on 2008-10-08
I have many rows being returned which contain a autonumber, qty, timestamp and foreignKeyID fields...what I need is to get the totalqty of all the rows, and the time difference between the latest timestamp and the earliest timestamp all based on the same foreign key ID
Based on these variables I need to see the totalqty/time difference ...which will give the # of units counted per minute.
I am using VB.Net and Sql Server 2005... I am just a bit fuzzy on the actual grabbing of the earliest & latest timestamp... I could use the AutoNumber field ( Max / Min) of the table based on the foreign key...but is there a better way...
Any help or insight would be much appreciated...