| Author |
Topic |
|
zubairmasoodi
Starting Member
35 Posts |
Posted - 2007-04-27 : 06:26:48
|
I have a Table with This format and Start up with Data as Shown TBL_UserSessionsSession_ID Student_ID Session_Date845 100 4/12/2007 0:00846 100 4/15/2007 2:09847 100 4/19/2007 5:32848 100 4/16/2007 5:56849 101 4/12/2007 0:00850 103 4/12/2007 0:00851 103 4/15/2007 0:00852 103 4/13/2007 0:00861 104 4/11/2007 0:00862 104 4/12/2007 0:00863 100 4/12/2007 0:00864 100 4/15/2007 2:09I want to Check out number of Sessions Each student has attended in the two input dates Suppose for StartDate= '4/12/2007' and EndDate= '4/15/2007'Is it Possible to get an Output of following format Student_ID 4/12/2007 4/13/2007 4/14/2007 4/15/2007 100 2 2 101 1 103 1 1 1104 1 Thanks In advance Learner ![]() |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-27 : 06:41:08
|
| Yes, with CROSSTAB/PIVOT query.Peter LarssonHelsingborg, Sweden |
 |
|
|
zubairmasoodi
Starting Member
35 Posts |
Posted - 2007-04-27 : 06:46:07
|
| Thanks I havent Heard about CrossTab/Pivot query Please help ! |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-27 : 06:52:28
|
| SELECT Student_ID, COUNT(*) AS TotalFROM TBL_UserSessionsWHERE Session_Date >= @StartDate AND Session_Date < DATEADD(DAY, 1, @EndDate)GROUP BY Student_IDORDER BY Student_IDPeter LarssonHelsingborg, Sweden |
 |
|
|
zubairmasoodi
Starting Member
35 Posts |
Posted - 2007-04-27 : 07:01:46
|
| This will Just give me the count of Sessions each student has attended, i want it datewise for each date between the start date and enddate Thanks |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-27 : 07:04:28
|
Can you do this in your front end reporting ? KH |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-27 : 07:06:19
|
| What about the dates NOT in the table?Example: You have Jan 1 and Jan 3 in the table.Do you want Jan 2 in the report?Peter LarssonHelsingborg, Sweden |
 |
|
|
zubairmasoodi
Starting Member
35 Posts |
Posted - 2007-04-27 : 07:07:26
|
| No That is My problem, it has to be exclusively done thru SQL PRocedure Thanks |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
zubairmasoodi
Starting Member
35 Posts |
Posted - 2007-04-27 : 07:09:24
|
| Yes Peso !!I want all the Dates that span between the Range. A value of Null for the field is desired for the date which is not in the Table data Thanks |
 |
|
|
|