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 use PIVOT with many tablse

Author  Topic 

sayer
Starting Member

35 Posts

Posted - 2013-04-20 : 08:31:21
[code]select
lesson_number as Lecture ,date,student.ID_student,dbo.FUN_names(student.frist_Name, student.Second_Name, student.Last_Name) AS name ,stae as state[/code]

from
[code]lecture ,
student_lectuer ,
Teacher_Course ,
student ,
section ,
course ,
Supervisor ,
TeachCourse_Super ,
teacher[/code]

where
[code]lecture.lesson_number=student_lectuer.FK_lesson_number
and
lecture.ID_Course_Teacher=Teacher_Course.id
and
student.ID_student=student_lectuer.fk_student_id
and
Teacher_Course.FK_Teacher_ID=teacher.Teacher_ID
and
Teacher_Course.FK_Course_ID=course.Coures_ID
and
Teacher_Course.FK_Section_ID=section.Section_ID
and
TeachCourse_Super.teacher_coures_ID=Teacher_Course.id
and
TeachCourse_Super.super_id=Supervisor.Super_ID
and
course.Coures_ID=102
and
section.Section_ID=3
[/code]
after execute select
Num_Lecture|date|id|name|state_absent
--------------------------------
1>>>>>>>2013-08-19>>>295>>>fahed>>>Yes
1>>>>>>>2013-08-19>>>291>>>sayer>>>no
3>>>>>>>2013-09-17>>>222>>>saleh>>>yes
4>>>>>>>2013-09-28>>>200>>>tlal>>>no
5>>>>>>2013-09-01>>>200>>>tlal>>>no
5>>>>>>>2013-09-01>>>222>>>saleh>>>no
6>>>>>>>2013-10-09>>>200>>>tlal>>>no
6>>>>>>>2013-10-09>>>222>>>saleh>>>yes
----------------------------------
i want number lecture in column and no repeat note:i have dynamic number of lecture

then

id and name in row

then

state print in cell
such as


>>>>>>>>>lecture>>1>>2>>3
id>>>name
222>>>saleh>>>>>>yes>>no>>yes
please help me


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

- Advertisement -