I have a SQL Server 2005 table in which I store the book exchanges that take place between two students.
ExchangeID BookID ExchangeDate FromPersName ToPersName
1 23 23.12.2011 John Matt
2 22 15.02.2012 Billy Ken
3 23 27.12.2011 Matt Riddley
5 23 05.03.2012 Riddley Josh
6 22 08.03.2012 Ken Rachel
7 23 19.03.2012 Josh Laura
8 23 15.01.2013 Laura Mike
9 22 17.01.2013 Rachel Stephanie
I want to generate a report for a specified year that looks like this:
Year:2012
BookID PersonName ReceivingDate DeliveryDate
23 Matt 01.01.2012 27.02.2012
23 Riddley 27.02.2012 05.03.2012
23 Josh 05.03.2012 19.03.2012
23 Laura 19.03.2012 31.12.2012
22 Ken 01.01.2012 08.03.2012
22 Rachel 08.03.2012 31.12.2012
This is half solution.You need to change it a litle bit to work. I will not make whole query for Your homework. Put some effort!
http://sqlfiddle.com/#!3/39d73/17