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.
| Author |
Topic |
|
sanjay5219
Posting Yak Master
240 Posts |
Posted - 2008-08-12 : 09:07:57
|
| Dear All,I have one table with below columnCustomer Id : Travel DateC1-01Aug 2008C2-02Aug 2008C1-03Aug 2008C1-04Aug 2008No i have to update another table with these columsnCustomer Id : Travel Date : Next Travel Date it should look like thisC1:01Aug 2008:03Aug 2008C1:03Aug 2008:04Aug 2008C2:02Aug2008:NULLplease tell me solution |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-12 : 09:43:47
|
| Are you using sql 2005? |
 |
|
|
sanjay5219
Posting Yak Master
240 Posts |
Posted - 2008-08-12 : 09:45:12
|
| Sql 2000 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-12 : 09:48:50
|
| [code]SELECT (SELECT COUNT(*) FROM YourTable WHERE CustomerId=t.CustomerId AND TravelDate < t.TravelDate) + 1 AS Seq,* INTO #TempFROM YourTable tINSERT INTO Table2SELECT t1.CustomerID,t1.TravelDate,t2.TravelDateFROM #Temp t1LEFT JOIN #Temp t2ON t1.CustomerID=t2.Customer_IDAND t2.Seq=t1.Seq+1[/code] |
 |
|
|
sanjay5219
Posting Yak Master
240 Posts |
Posted - 2008-08-12 : 10:01:40
|
| I have one doubt I have two table T1 table from where i have to extarct the date and table T2 where i have to update Next Travel Date.Which table will come in first query <YourTable> |
 |
|
|
sanjay5219
Posting Yak Master
240 Posts |
Posted - 2008-08-12 : 12:14:38
|
| No it is not solving my problem |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-08-12 : 12:18:52
|
quote: Originally posted by sanjay5219 No it is not solving my problem
Why?what was error? |
 |
|
|
|
|
|