Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | 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 use PIVOT with many tablse
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sayer
Starting Member

Saudi Arabia
35 Posts

Posted - 04/20/2013 :  08:31:21  Show Profile  Reply with Quote
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


from
lecture ,
student_lectuer ,
Teacher_Course ,
student ,
section  , 
course  ,
Supervisor ,
TeachCourse_Super ,
teacher


where
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

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
???? ???? ???????
  Previous Topic Topic Next 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.05 seconds. Powered By: Snitz Forums 2000