jon24422531
Technical User
Hi guys
I am not sure why this doen't work, and can I use a @Table in an ASP Page?
This works:
But this doesn't:
Many thanks
Jonathan
I am not sure why this doen't work, and can I use a @Table in an ASP Page?
This works:
Code:
strSQL3 = " SELECT UPPER(D.UserID)AS UserID, ISNULL(A.cnt, '0') AS [OPEN], ISNULL(B.cnt, '0') AS [ON-HOLD], ISNULL(c.cnt, '0') AS [DEVELOPMENT], D.cnt AS [Total] FROM" & _
" (SELECT DISTINCT(UserID) AS UserID, Count(*) as cnt FROM WorkLog..WorkLog WHERE Finished != 'CLOSED' Group By UserID) D" & _
" LEFT OUTER JOIN" & _
" (SELECT DISTINCT(UserID) AS UserID, Count(*) as cnt FROM WorkLog..WorkLog WHERE Finished = 'open' Group By UserID) A on D.UserID = A.UserID" & _
" LEFT OUTER JOIN" & _
" (SELECT DISTINCT(UserID) AS UserID, Count(*) as cnt FROM WorkLog..WorkLog WHERE Finished = 'On-Hold' Group By UserID) B on D.UserID = B.UserID" & _
" LEFT OUTER JOIN" & _
" (SELECT DISTINCT(UserID) AS UserID, Count(*) as cnt FROM WorkLog..WorkLog WHERE Finished = 'Development' Group By UserID) C on D.UserID = C.UserID"
But this doesn't:
Code:
strSQL3 = [COLOR=blue]"DECLARE @T Table(UserID VARCHAR(25), [Open] int, [On-Hold] int, [Development] int, Total int)" & _
" Insert into @T" & _ [/color]
" SELECT UPPER(D.UserID)AS UserID, ISNULL(A.cnt, '0') AS [OPEN], ISNULL(B.cnt, '0') AS [ON-HOLD], ISNULL(c.cnt, '0') AS [DEVELOPMENT], D.cnt AS [Total] FROM" & _
" (SELECT DISTINCT(UserID) AS UserID, Count(*) as cnt FROM WorkLog..WorkLog WHERE Finished != 'CLOSED' Group By UserID) D" & _
" LEFT OUTER JOIN" & _
" (SELECT DISTINCT(UserID) AS UserID, Count(*) as cnt FROM WorkLog..WorkLog WHERE Finished = 'open' Group By UserID) A on D.UserID = A.UserID" & _
" LEFT OUTER JOIN" & _
" (SELECT DISTINCT(UserID) AS UserID, Count(*) as cnt FROM WorkLog..WorkLog WHERE Finished = 'On-Hold' Group By UserID) B on D.UserID = B.UserID" & _
" LEFT OUTER JOIN" & _
" (SELECT DISTINCT(UserID) AS UserID, Count(*) as cnt FROM WorkLog..WorkLog WHERE Finished = 'Development' Group By UserID) C on D.UserID = C.UserID" & _
[COLOR=blue]" Select * from @T ORDER BY [Open] DESC"[/color]
Many thanks
Jonathan