Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 SQL Query

Author  Topic 

sr_aneesh
Starting Member

17 Posts

Posted - 2005-12-17 : 04:35:37
I have two Tables Customer and Visit
I want to display the next 4 visit Dates Against Each Customer

Customer Table

ID Customer1

1 Customer1
2 Customer2
3 Customer3
4 Customer4
5 Customer5
6 Customer6



Visit Table

CustomerId VisitDate
3 12/15/2005
4 12/10/2005
2 12/22/2005
3 12/22/2005
1 12/22/2005
3 12/29/2005
2 12/25/2005




Which should Display as (Following are dummy data)


Customer Name Visit1 Visit2 Visit3 Visit4
Customer 1 12/15/2005 12/18/2005 12/21/2005 12/24/2005
Customer 2 12/13/2005 12/16/2005 12/25/2005
Customer 3 12/14/2005 12/20/2005
Customer 4 12/16/2005 12/19/2005 12/26/2005
Customer 5 12/19/2005 12/22/2005
Customer 6 12/6/2005 12/18/2005
Customer 7 12/25/2005 12/26/2005 12/28/2005 12/29/2005



Thanx in Advance

activecrypt
Posting Yak Master

165 Posts

Posted - 2005-12-17 : 05:42:34
Hi,
add 3 days (as you said its 3 days) in visit1 then visit2 and as on , use dateadd function then

:-)
Regards

Andy Davis
Activecrypt Team
--------------------------------------------
SQL Server Encryption Software
http://www.activecrypt.com
Go to Top of Page
   

- Advertisement -