Using the current twoi functions you may not able to nest. You might need to amend the secong funstion to include fields which are needed for taking join condition with rest of tables (ZSRIVENDEL.dbo.pc_CourseTitles,ZSRIVENDEL.dbo.cam_topics) and once its done you can nest them likeRETURN(SELECT us.LastName, us.FirstName, us.[Time Spent(MIN)],Max(us.time_stamp) AS [Last Log Date], pct.Title, cat.topic_name FROM UserSummary(parameters in correct order) usinner join ZSRIVENDEL.dbo.pc_CourseTitles pcton us.course_id = pct.CourseID inner join ZSRIVENDEL.dbo.cam_topics caton us.topic_id = cat.topic_idWHERE (pct.ClientID=@ClientID) GROUP BY us.LastName, us.FirstName, pct.Title, cat.topic_name)
and user summary will beSELECT ut.LastName, ut.FirstName,hu.time_stamp,hu.course_id,hu.topic_id,CEILING(SUM(hu.Session_Time) / 60000.0) AS [Time Spent(MIN)]FROM ZSRIVENDEL.dbo.UserTable AS utINNER JOIN ZSRIVENDEL.dbo.History_Usage AS hu ON hu.Student_ID = ut.Student_IDWHERE ut.ClientID = @ClientIDAND ut.GroupID = 3400AND hu.Time_Stamp >= @StartDateAND hu.Time_Stamp < @EndDateAND hu.Session_Time < 21600000GROUP BY ut.LastName, ut.FirstName)