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 |
|
ganeshkumar08
Posting Yak Master
187 Posts |
Posted - 2008-06-30 : 05:06:59
|
| Hi,I have a following Tables.1. TrendSelected_Matches-------------------------SessionID MatchId-------------------------0 8------------------------2. trendSelected_Players-------------------------SessionID PlayerID-------------------------0 700 134-------------------------For each match we have Max(Time) in another table. The time is in seconds.3. MaxTimeTable-----------------------------MatchID MaxTime-----------------------------8 5800-----------------------------My question is i have to insert matchId, playerid in another temporary table with Time division of 900 sec each playerid.ie., My output should be like---------------------------------------------MatchID Playerid TimeStart TimeEnd---------------------------------------------8 70 0 9008 70 901 18008 70 1801 27008 70 2701 36008 70 3601 45008 70 4501 54008 70 5401 5800 i.e, max time8 134 0 9008 134 901 18008 134 1801 27008 134 2701 36008 134 3601 45008 134 4501 54008 134 5401 5800 i.e, max timeHow can get like aboveThanksGaneshSolutions are easy. Understanding the problem, now, that's the hard part |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-30 : 05:23:58
|
| [code]INSERT INTO YourTableSELECT m.MatchID,p.PlayerID,900 * v.number+ CASE WHEN v.number<>0 THEN 1 ELSE 0 END,900*(v.number+1)FROM TrendSelected_Matches mINNER JOIN trendSelected_Players pON p.SesionID=m.SessionIDINNER JOIN MaxTimeTable tON t.MatchID=m.MatchIDCROSS JOIN master..spt_values vWHERE v.Type='p'AND 900*(v.number+1) <=t.MaxTime[/code] |
 |
|
|
ganeshkumar08
Posting Yak Master
187 Posts |
Posted - 2008-06-30 : 05:54:05
|
| thank you visakh. |
 |
|
|
|
|
|