Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2000-10-26 : 20:15:56
|
Calvin writes "I have a SQL statement as follows:
SELECT S1.ID, LEFT(EmailAddress,INSTR(S1.EmailAddress,'@')-1) AS Mailbox, Mid(EmailAddress,INSTR(EmailAddress,'@')+1) AS Dom,
(SELECT COUNT(*) FROM NewLoginTable WHERE UserID=S1.ID AND DateLoggedIn BETWEEN #" & dtmFrom & " 0:00:00# AND #" & dtmTo & " 23:59:59# GROUP BY UserID) AS LoginNumber,
(SELECT MAX(ViewDate) FROM USER_DocCount WHERE USERID=S1.ID AND ViewDate BETWEEN #" & dtmFrom & "# AND #" & dtmTo & "# GROUP BY USERID) AS LastLoginTime,
(SELECT COUNT(*) FROM User_DocCount WHERE UserID=S1.ID AND ViewDate BETWEEN #" & dtmFrom & "# AND #" & dtmTo & "# GROUP BY UserID) AS DocsSeen
FROM USER_INFO S1 INNER JOIN UserDocs ON S1.ID = UserDocs.USERID
WHERE S1.ID=ANY (SELECT USERID FROM USER_DocCount WHERE ViewDate BETWEEN #" & dtmFrom &"# AND #"& dtmTo &"#);
The problem is I can't get the data to sort by the calculated fields which are the fields I'm getting from the Sub queries. Help!" |
|
|
|
|
|