Hai friends...
Iam doing school related application in that i have to diplay time table.i have taken one table namely classTimeTable in that fields are StaffId,ClassName,Subject,Days(ex:monday,tuesday..),time,PreiodNo.so here i need to display time table based on class or StaffID..
can any one suggest me the better way to display timetable..
Loading

Rahul BhattPosted Jul 20, 2012, 5:29 AM
For that,
First Create Table
CREATE TABLE [classtimetable](
[StaffId] [int] NULL,
[ClassName] [varchar](50) NULL,
[Subject] [varchar](50) NULL,
[Days] [varchar](50) NULL,
[time] [varchar](10) NULL,
[PeriodNo] [int] NULL
) ON [PRIMARY]
After then Insert Value into this Table
Now using PIVOT Table you can easily Get Classwise TimeTable
SELECT time, PeriodNo, [Monday],[Tuesday],[WenesDay],[Thursday],[Friday],[Saturday]
FROM
(
SELECT sp.Days, sp.Subject+'('+CAST(sp.StaffId as varchar)+')' as ObjectName,sp.time,sp.PeriodNo
FROM classtimetable as sp where sp.ClassName='5A'
) p
PIVOT
(
MAX(ObjectName )
FOR Days
IN ([Monday],[Tuesday],[WenesDay],[Thursday],[Friday],[Saturday])
) AS pvt
Output : This TimeTable is for Std 5A Class.
() indicate Staff ID
time
PeriodNo
Monday
Tuesday
WenesDay
Thursday
Friday
Saturday
07-Aug
1
English(1)
Maths(4)
Computer(7)
English(1)
Gujarat(3)
PT(9)
8-9.30
2
Sanskrit(2)
Science(5)
Science(5)
Music(8)
SS(6)
PT(9)
10:30-12
3
Gujarat(3)
SS(6)
Maths(4)
Maths(4)
Science(5)
Drawing(10)
divyaPosted Jul 20, 2012, 6:23 AM
raj kiranPosted Jul 20, 2012, 4:36 AM