Sql output without using loop

Posted by Santosh4u under Sql Server on 1/11/2013 | Points: 10 | Views : 833 | Status : [Member] | Replies : 3
Hi
could you please help me to get the output without using loop...

Input :

Srno Department CreatedDate UpdateDate
1 HR 07/12/2012 10:30 07/12/2012 10:30
2 HR 07/12/2012 10:41 07/12/2012 10:41
3 HR 08/12/2012 07:08 08/12/2012 07:08
4 Development 07/12/2012 10:30 07/12/2012 10:30
5 Development 07/12/2012 11:33 07/12/2012 11:33
6 Testing 07/12/2012 17:18 07/12/2012 17:18
7 Testing 07/12/2012 10:31 07/12/2012 10:31
8 Testing 07/12/2012 11:38 07/12/2012 11:38

Output : shoube be like below without using any loop becaz it's taking more time to loop through..
Current row createddate should be updated as next row updatedate..

Srno Department CreatedDate UpdateDate
1 HR 07/12/2012 10:30 Null
2 HR 07/12/2012 10:41 07/12/2012 10:30
3 HR 08/12/2012 07:08 07/12/2012 10:41
4 Development 07/12/2012 10:30 null
5 Development 07/12/2012 11:33 07/12/2012 10:30
6 Testing 07/12/2012 17:18 Null
7 Testing 07/12/2012 10:31 07/12/2012 17:18
8 Testing 07/12/2012 11:38 07/12/2012 10:31




Thanks in adv.
santosh




Responses

Posted by: Shubham on: 1/12/2013 [Member] Starter | Points: 25

Up
0
Down
Hi!!! Santosh4u
from where can u insert this query???
window or web app..
or are u using textbox ????

Thanks&Regards:-
Shubham Choudhary
Software Engineer
www.facebook.com/shubham.kunar

Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Santosh4u on: 1/12/2013 [Member] Bronze | Points: 25

Up
0
Down
Hi Shubham,
i just need this in sqlserver...don't worry about web or windows application..

just i need the sql query for this..

u can see the attachment..

Thanks
Santosh
 Download source file

Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prashikudupi on: 1/23/2013 [Member] Starter | Points: 25

Up
0
Down
Hi,

Please chk Highlighted date below. As Update dt can not be less than Created Date. Is that the way u are expecting?

Srno Department CreatedDate UpdateDate
1 HR 07/12/2012 10:30 Null
2 HR 07/12/2012 10:41 07/12/2012 10:30
3 HR 08/12/2012 07:08 07/12/2012 10:41
4 Development 07/12/2012 10:30 null
5 Development 07/12/2012 11:33 07/12/2012 10:30
6 Testing 07/12/2012 17:18 Null
7 Testing 07/12/2012 10:31 07/12/2012 17:18
8 Testing 07/12/2012 11:38 07/12/2012 10:31

http://sqlbay.blogspot.in/ 


Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response