Click here to Skip to main content
15,942,292 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,
A) mark details table contain following column
1.markid, 2.Examid,3.subjectid,4.admissionnumber,5.markobtained,6.classid 7.mark

B) Subject_registration contain
1.subjectid 2.subjectname and etc.

C) class_details contain
1.classid,2.classname and etc

D) studentAdmission_table contains
1.admissionnumber,2.studentname and etc

E) Rollnumber_details contain
1.admissionnumber 2.rollnumber and etc.

from mark_details I want to select data as

AdmissionNumber Rollnumber Name subject1 subject2 subject3

for particular class.

which method is useful for getting answer.In this cases based on the class subjectName and no.of subject could be changed. I am very new to this. please help
me

[Edit]Comments from OP
sorry my question is wrong typed.
for example
mark _details table contain
SQL
markid  examid subjectid  admissionumber  mark  classid
 1       2        23011      100            89   12
 2       2        23012      100            87   12
 3       2        23013      100            77   12
 4       2        23011      101            98   12
 5       2        23012      101            78   12
 6       2        23013      101            78   12


I want like this
SQL
Rollnumber   admissionumber  name  subject1(23011)  subject(23012) subject(23013)
1001              100        XXXX    89                87               77


for classid 12.

Is pivot operator for this desired result? if the no of subjects for all class same mean we can use pivot. but here how can solve this?

[/Edit]

Thank you
Posted
Updated 18-Dec-12 21:48pm
v4
Comments
Abhishek Pant 19-Dec-12 3:16am    
use stored procedure.
[no name] 19-Dec-12 3:37am    
What have you tried so far ??
baskaran chellasamy 19-Dec-12 3:40am    
sorry my question is wrong typed.
for example
mark _details table contain
markid examid subjectid admissionumber mark classid
1 2 23011 100 89 12
2 2 23012 100 87 12
3 2 23013 100 77 12
4 2 23011 101 98 12
5 2 23012 101 78 12
6 2 23013 101 78 12

I want like this
Rollnumber admissionumber name subject1(23011) subject(23012) subject(23013)
1001 100 XXXX 89 87 77

for classid 12.

Is pivot operator for this desired result? if the no of subjects for all class same mean we can use pivot. but here how can solve this?

1 solution

SQL Server PIVOThttp://msdn.microsoft.com/en-us/library/ms177410%28v=sql.105%29.aspx[^] command might be useful to you.
Try http://blog.sqlauthority.com/2008/06/07/sql-server-pivot-and-unpivot-table-examples/[^] as well.

There are a number of other useful resources that you can locate if you do a search for PIVOT.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900