Click here to Skip to main content
15,891,529 members
Home / Discussions / Database
   

Database

 
GeneralRe: Query to find last 10 records Pin
That's Aragon8-Feb-08 21:56
That's Aragon8-Feb-08 21:56 
GeneralRe: Query to find last 10 records Pin
Sabarinathan T8-Feb-08 22:20
Sabarinathan T8-Feb-08 22:20 
GeneralRe: Query to find last 10 records Pin
sirisha guttikonda8-Feb-08 23:22
sirisha guttikonda8-Feb-08 23:22 
QuestionSyntax help - How to subtract two years from current date Pin
Smokeywade8-Feb-08 7:40
Smokeywade8-Feb-08 7:40 
GeneralRe: Syntax help - How to subtract two years from current date Pin
AlbertEiki8-Feb-08 7:46
AlbertEiki8-Feb-08 7:46 
AnswerRe: Syntax help - How to subtract two years from current date Pin
Pallab_GT9-Feb-08 7:53
Pallab_GT9-Feb-08 7:53 
GeneralAggregate Function [modified] Pin
Lash208-Feb-08 3:37
Lash208-Feb-08 3:37 
GeneralRe: Aggregate Function Pin
Michael Potter8-Feb-08 4:45
Michael Potter8-Feb-08 4:45 
It should go out-of-whack when you add class name since you would then be asking the server to give you the first attendance date of EACH class each student took. I have to assume that a student can take multiple classes in a day and that AttendanceDate does not respect the time of the class (only the date).

Here is a messy start that should work on SQL Server. I used your original query to aquire the necessary root data for finding the first class name. TOP 1 is used in case the student attends more than 1 class that day and time is not embedded in AttendanceDate.
SELECT 
    EmployeeID,
    FullName,
    FirstAttendanceDate,
    (SELECT TOP 1
         tblClass.className
     FROM
         tblAttendance
     INNER JOIN 
         tblClassInstance 
         ON (tblAttendance.ClassInstanceID = tblClassInstance.ClassInstanceID)
     INNER JOIN 
         tblClass 
         ON (tblClassInstance.ClassID = tblClass.ClassID)
     WHERE 
         tblAttendance.EmployeeID = root.EmployeeId,
         tblAttendance.AttendanceDate = root.FirstAttendanceDate) AS ClassName
FROM		
    (SELECT 
          tblAttendance.EmployeeID, 
          vwEmployeeInformation.FullName, 
          MIN(tblAttendance.AttendanceDate) AS FirstAttendanceDate
     FROM 
          tblAttendance
     INNER JOIN 
          tblClassInstance 
          ON (tblAttendance.ClassInstanceID = tblClassInstance.ClassInstanceID)
     INNER JOIN 
          tblClass 
          ON (tblClassInstance.ClassID = tblClass.ClassID)
     INNER JOIN 
          vwEmployeeInformation 
          ON (tblAttendance.EmployeeID = vwEmployeeInformation.EmployeeID)
     WHERE 
          (tblClass.ClassFormat = 'On Demand') AND 
          (tblAttendance.AttendanceDate BETWEEN '08/10/07' AND GetDate())
     GROUP BY 
          tblAttendance.EmployeeID, 
          vwEmployeeInformation.FullName) AS Root 

GeneralRe: Aggregate Function Pin
Lash208-Feb-08 5:20
Lash208-Feb-08 5:20 
Generalexporting sqlserver table data into .csv files Pin
rajeshkumar g8-Feb-08 1:05
rajeshkumar g8-Feb-08 1:05 
GeneralRe: exporting sqlserver table data into .csv files Pin
Giorgi Dalakishvili8-Feb-08 1:22
mentorGiorgi Dalakishvili8-Feb-08 1:22 
GeneralRe: exporting sqlserver table data into .csv files Pin
rajeshkumar g10-Feb-08 22:26
rajeshkumar g10-Feb-08 22:26 
GeneralRe: exporting sqlserver table data into .csv files Pin
Vasudevan Deepak Kumar12-Feb-08 2:48
Vasudevan Deepak Kumar12-Feb-08 2:48 
GeneralSQL2005 + Service Broker + CLR Stored Procedure + XML + Temp Tables Pin
Malcolm Smart7-Feb-08 23:57
Malcolm Smart7-Feb-08 23:57 
GeneralCrystal Report Pin
techpub7-Feb-08 23:22
techpub7-Feb-08 23:22 
GeneralRe: Crystal Report Pin
John_Adams8-Feb-08 1:09
John_Adams8-Feb-08 1:09 
GeneralRe: Crystal Report Pin
techpub8-Feb-08 3:26
techpub8-Feb-08 3:26 
Generalmail send using sqlserver2000 Pin
Member 38798817-Feb-08 18:16
Member 38798817-Feb-08 18:16 
GeneralRe: mail send using sqlserver2000 Pin
That's Aragon7-Feb-08 18:43
That's Aragon7-Feb-08 18:43 
GeneralORDER BY Pin
uglyeyes7-Feb-08 13:14
uglyeyes7-Feb-08 13:14 
GeneralRe: ORDER BY Pin
pmarfleet7-Feb-08 21:33
pmarfleet7-Feb-08 21:33 
GeneralRe: ORDER BY Pin
Krish - KP7-Feb-08 21:37
Krish - KP7-Feb-08 21:37 
QuestionHow to insert a data after upading the table Pin
Exelioindia7-Feb-08 9:45
Exelioindia7-Feb-08 9:45 
AnswerRe: How to insert a data after upading the table Pin
pmarfleet7-Feb-08 10:36
pmarfleet7-Feb-08 10:36 
Generalneed help Pin
haseeb_saeed7-Feb-08 9:13
haseeb_saeed7-Feb-08 9:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.