Query Help

  • This is what I did guys...Sorry I din't post my query earlier...

    IF OBJECT_ID('tempdb..#proj') IS NOT NULL DROP TABLE #proj

    SELECT DISTINCT T1.ProjID

    into #proj FROM ProjectComments t1

    join proj t2 on t1.projid = t2.projid

    WHERE t2.StatusID NOT IN (2,3)

    SELECT #proj.*, t2.id, t2.Comments, t2.DateSubmitted, t2.EmpID

    FROM #proj

    OUTER APPLY

    (

    SELECT TOP 5 * FROM ProjectComments

    WHERE #proj.ProjID = ProjectComments.ProjID

    ORDER BY DateSubmitted DESC) as t2

    ORDER BY ProjID

  • Thank you for posting your code. But may I suggest that you take a look at the code I posted as well? Test them out side by side and go from there.

Viewing 2 posts - 16 through 16 (of 16 total)

You must be logged in to reply to this topic. Login to reply