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 |
|
sunsanvin
Master Smack Fu Yak Hacker
1274 Posts |
Posted - 2007-03-08 : 01:44:38
|
| Dear Friends, I've created one table, with the following attributes.everything is ok, but while retrieving data, the question numbers should be starting from 1,2.......... but i'm not getting that result. please suggest me to the output like that.--create table question_code_level (qno int,code varchar(10),level varchar(10),question varchar(500),option1 varchar(200),option2 varchar(200),option3 varchar(200),option4 varchar(200),option5 varchar(200))select * from question_code_level 1 html beginer what is clr? something something something something something2 c# beginer what is clr? something something something something something3 c# expert what is clr? something something something something something4 c# intermedia what is clr? something something something something something5 c# beginer what is clr? something something something something something6 vb beginer what is clr? something something something something something7 html expert what is clr? something something something something something8 sqlserver intermedia what is clr? something something something something something10 oracle beginer what is clr? something something something something something11 java beginer what is clr? something something something something something12 java expert what is clr? something something something something something13 sqlserver beginer what is clr? something something something something something--select * from question_code_level where code='c#' and level='beginer'2 c# beginer what is clr? something something something something something5 c# beginer what is clr? something something something something somethingVinod |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-08 : 01:48:17
|
| If you are giving WHERE condition to select only C# beginner questions, how do you expect it to bring back 1st record which is for html beginner?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-08 : 01:48:53
|
Do the numbering in your front end application. KH |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-03-08 : 01:49:57
|
| select row_number() over (order by qno) as new_qno, code, level, question, option1, option2, option3, option4, option5from question_code_level where code = 'c#' and level = 'beginner'Peter LarssonHelsingborg, Sweden |
 |
|
|
sunsanvin
Master Smack Fu Yak Hacker
1274 Posts |
Posted - 2007-03-08 : 01:56:57
|
| Dear Peso, what is row_number() ?i didnt get this? please explain meVinod |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-08 : 02:04:46
|
| row_number() is built-in function provided in SQL Server 2005. It will number the records based on certain column order. (as given by ORDER BY clause)Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
sunsanvin
Master Smack Fu Yak Hacker
1274 Posts |
Posted - 2007-03-08 : 02:08:22
|
| i've only sqlserver2000. that is the reason i'm not getting the result. is there any equialent function in sql server2000?and what is the wrong in this query? please see thisselect * into temp1 from (select * from question_code_level where code='c#' and level='beginer')Vinod |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-08 : 02:26:06
|
you need to named your derived tableselect * into temp1 from (select * from question_code_level where code='c#' and level='beginer') a KH |
 |
|
|
|
|
|
|
|