arprilia Posted July 2, 2007 Share Posted July 2, 2007 Greetings 2 all.... i've encountered some difficulties with my query here. is it possible to have datediff function for 2 records? table id yearofsale 1 2006 2 2003 3 2001 4 1998 can i query for first row minus second row, second row minus third row, and so on.... ??? ??? ??? on the other hand, how can i do it in php? thanx.... Quote Link to comment https://forums.phpfreaks.com/topic/58049-datediff-from-2-records/ Share on other sites More sharing options...
Illusion Posted July 2, 2007 Share Posted July 2, 2007 select DATEDIFF(a.yearofsale,b.yearofsale) from a INNER JOIN (select yearofsale from a ) as b on a.id=b.id+1; a self join will also work .......... Quote Link to comment https://forums.phpfreaks.com/topic/58049-datediff-from-2-records/#findComment-287810 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.