Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
More from the grouping
Message
De
15/09/2010 16:11:00
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
More from the grouping
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01481344
Message ID:
01481344
Vues:
86
This afternoon, and thanks to those who helped me with those SQL, I was able to define the required SQL I was looking for. This works. Basically, the actual command is:
SELECT RO.FirstName
FROM (SELECT TOP 10 Event.RO_No,Min(Event.DateTime) AS LastUpdate
 FROM Event
 INNER JOIN RO ON Temp.RO_No=RO.RO_No
 GROUP BY Event.RO_No
 ORDER BY MIN(Event.Datetime)) Temp
INNER JOIN RO ON Temp.RO_No=RO.RO_No
So, this returns something like this:
Ro_No       DateTime
  1         2007-12-17 14:41:25.704
  3         2007-12-17 14:42:25.704
  7         2007-12-17 14:43:25.704
 22         2007-12-18 15:41:25.704
 23         2007-12-19 16:41:25.704
 24         2008-12-20 07:41:25.704
 25         2009-12-17 08:41:25.704
 46         2009-12-17 05:41:25.704
 48         2009-12-18 05:41:25.704
 49         2009-12-19 14:41:25.704
But, Ro_No, in the Event table appears in multiple records. The reason is that the Event table logs everything when there is a change in the record. So, I have a robot process which processes 10 records at a time. So, in the next loop, it will execute the same SQL again and obtain a new batch of 10 records. However, in that new batch, I may end up with a RO_No that I already processed. In our design, there is only a need to process the last one from the Event table. I do not know if that is possible here, if that would require a derived SQL or else.

The problem I have presently is that I have about 2000 records to process. So, this would make it 200 times. But, I only have 56 records in the RO table. So, at most, if I can refine this SQL, I would only have to do 6 loops.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform