SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 how to retrieve data like this structuer
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sayer
Starting Member

Saudi Arabia
35 Posts

Posted - 04/19/2013 :  09:04:02  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3701 Posts

Posted - 04/19/2013 :  09:17:41  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
2217 Posts

Posted - 04/19/2013 :  09:19:32  Show Profile  Reply with Quote
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

Saudi Arabia
35 Posts

Posted - 04/19/2013 :  09:27:21  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.16 seconds. Powered By: Snitz Forums 2000