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.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 how to retrieve data like this structuer

Author  Topic 

sayer
Starting Member

35 Posts

Posted - 2013-04-19 : 09:04:02
i have 30 lecture and every lecture has many students

how to put lecture in column and students in row such as

1 2 3 4 5 6 7 8 9 <number of lectures
| ---------------------------------------------

299 yes no yes no

22 yes no yes no
111 yes no yes no

11 yes no yes no

2223



select
lesson_number ,date,S.ID_student,dbo.FUN_names(S.frist_Name, S.Second_Name, S.Last_Name) AS name
from
lecture L,
student_lectuer SL,
Teacher_Course TC,
student S,
section se ,
course c ,
Supervisor SP,
TeachCourse_Super TCSP,
teacher t
where
L.lesson_number=sl.FK_lesson_number
and
L.ID_Course_Teacher=TC.id
and
S.ID_student=sl.fk_student_id
and
tc.FK_Teacher_ID=t.Teacher_ID
and
tc.FK_Course_ID=c.Coures_ID
and
tc.FK_Section_ID=se.Section_ID
and
tcsp.teacher_coures_ID=tc.id
and
tcsp.super_id=sp.Super_ID
and
c.Coures_ID=102
--and
--se.Section_ID=3

please help me

http://aman-services.net
for office
???? ???? ???????

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-04-19 : 09:17:41
I assume the column labels 1,2,3 etc. are lecture numbers. What does the data in column 1 (299, 22 etc.) represent, and what does Yes or No values in the other columns represent?

It would be much easier for someone to respond if you post some sample data and table schema in a consumable format. Take a look at this page to see how you might generate such data: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-04-19 : 09:19:32
we can convert columns to rows by using PIVOT..
Post the sample data of your table... and expected output clearly..

--
Chandu
Go to Top of Page

sayer
Starting Member

35 Posts

Posted - 2013-04-19 : 09:27:21
What does the data in column 1 (299, 22 etc.) >>> id student
what does Yes or No values in >> state of present & absent in lecture

http://aman-services.net
for office
???? ???? ???????
Go to Top of Page
   

- Advertisement -