General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
>That's a great recomendation, this thread comes as a way to know how to improve the >FROM clause and correlated sentences with the new VFP9 UPDATE-SQL feature.
Well, with VFP9 you can also do subqueries and therefore it can also be done this way in one SQL-Update:
Update cAgent ;
SET yMonth = t2.YTot ;
FROM (Select iAgentID, Sum(yAmount) As YTot ;
FROM cMovs GROUP BY 1 ;
WHERE Year(dDate) = 2005 And Month(dDate) = 1) as t2;
WHERE t2.iAgentID = cAgent.iAgentID ;
AND cAgent.nYear = 2005 AND cAgent.nMonth = 1
But that doesn't make it faster than the two selects done one after another.
I'd say the speed would be improved if records in cMovs were physically ordered by time, because although a index speeds things up, if the hard disk drive head doesn#t have to move much, it may even get faster. And normally the records would be in time order, wouldn't they?
Bye, Olaf.
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only