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 |
|
korssane
Posting Yak Master
104 Posts |
Posted - 2009-09-15 : 10:55:45
|
| Hi ALl , is there a way to use a loop statement into a table in order to assign those values or compare them in a select statement.Basically the issue is :i am generating a top 5 issues with their count ( issuename, Count) by descending order for a current week and current day.I want to compare the current Count with the last week one for the same issuenames on the same day.Week :1,2,3....53Day : 1,..7.What i have done till now is to put all the curent issuenames and count into a table ...My idea is to pull the last week issuenames and count where the lastweek issuename equals the table element (i,j)..Any help please will be appreciated.. i am really stucked.. |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2009-09-15 : 11:03:21
|
table structure, sample data and expected result will be helpful KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
korssane
Posting Yak Master
104 Posts |
Posted - 2009-09-15 : 11:05:40
|
| thanks Khtan,but did not catch any thing..more details please if possible.. |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
|
|
korssane
Posting Yak Master
104 Posts |
Posted - 2009-09-15 : 11:49:38
|
| i am new guys..my code is below :Select t1.issue1,t1.issue2,t1.Count, (select t2.issue1,t2.issue2,t2.Count where ( t2.issue1 = t1.issue1 AND t2.issue2 = t1.issue2 AND t1.Week=@WeekBefore and t1.day=@today ),From table1 t1Where (t1.Week=@currenweek and t1.day=@today)basically i want to compare Count of issue 1,2 of this week with the one of the same issue1,2 of the last week.please help.. |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-09-15 : 13:43:20
|
quote: i am new guys..my code is below :
korssane, your requirments, as stated, are just not clear enough to provide a working solution. We could take some guesses but that usually just wastes everyone's time. The link I posted is specifically for "new" people. It is detailed instructions on what to provide to get a quick and helpful answer.Be One with the OptimizerTG |
 |
|
|
|
|
|
|
|