fxr Posted March 22, 2008 Share Posted March 22, 2008 hi i am working on a web application and i am stuck.. i have a table that looks like this: ....time.........................quote....dif | 2008-03-17 00:00:00 | 15000 | | | 2008-03-17 00:30:00 | 15002 | | | 2008-03-17 01:00:00 | 15004 | | | 2008-03-17 01:30:00 | 15006 | | | 2008-03-17 02:00:00 | 15008 | | | 2008-03-17 02:30:00 | 15010 | | | 2008-03-17 03:00:00 | 15008 | | | 2008-03-17 03:30:00 | 15006 | | | 2008-03-17 04:00:00 | 15004 | | | 2008-03-17 04:30:00 | 15002 | | | 2008-03-17 05:00:00 | 15000 | | | 2008-03-17 05:30:00 | 15002 | | | 2008-03-17 06:00:00 | 15004 | | | 2008-03-17 06:30:00 | 15006 | | | 2008-03-17 07:00:00 | 15008 | | ..etc etc i wanna work out the difference in the quote from the previous 30 minutes and store it in the diff field e.g | 2008-03-17 00:00:00 | 15000 | null/0 | | 2008-03-17 00:30:00 | 15002 | 2 | | 2008-03-17 01:00:00 | 15004 | 2 | ..etc.etc can i do this with a stored procedure or something? or should i use a script..? i just need a nudge in the right direction.. thanks. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 25, 2008 Share Posted March 25, 2008 Do you really need to store this? Quote Link to comment Share on other sites More sharing options...
aschk Posted March 26, 2008 Share Posted March 26, 2008 Wow, makes my head spin. Hmm... You need a self JOIN , on 1 row only. I'll give it some thought. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 26, 2008 Share Posted March 26, 2008 You could always use and order by clause and some user variables. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.