Hi yaar,
I am doing project in Asp.net using c# codings.
My backend is ms sqlserver
I stored 100 questions in my database table.
From 1 to 20 questions my subtopic name is introduction
21 to 40 questions subtopic name is loop
41 to 60 questions my subtopic name is functions
61 to 80 questions my subtopic name is pointers
81 to 100 questions my subtopic name is structures and unions
My question is...?
I want to display those subtopics name in the same order like (introduction, loop , functions ,pointers, structures and unions)
what is the sql query to order the subtopic in the same order by using my question number.
Loading
Arul ManivannanPosted Mar 21, 2013, 5:01 AM
You dint tell that what are the columns in the table or have you created the column called subtopic??
Anyway here is the sql query,
Select A.col1,A.col2,A.col3,A.subtopic,a.questionno,a.questionorder from (Select col1,col2,col3 , subtopic,questionno
,case when subtopic = 'introduction' then 1
when subtopic = 'loop' then 2
when subtopic = 'functions' then 3
when subtopic = 'pointers ' then 4
when subtopic = 'structures and unions' then 4 else null end as [QuestionOrder]
from tablename)A
order by a.questionorder asc,a.questionno asc
With this query you can set your own order in the "case when" statement
Please reply in case of clarifications required
Arul Manivannan