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.

 All Forums
 Other Forums
 MS Access
 Sorting Data After calculating from other tables

Author  Topic 

DustinTX2000
Starting Member

1 Post

Posted - 2000-09-26 : 13:06:32
I am needing to sort calculated fields in a recordset.

SQL Statement is like this:

SELECT S1.ID, LEFT(EmailAddress,INSTR(EmailAddress,"@")-1) As MailBox,
MID(EmailAddress,INSTR(EmailAddress,"@")+1) As Dmn,

(SELECT Count(*) FROM USER_LOGINS WHERE USERID = S1.ID) As LoginCount,

(SELECT Max(ViewDate) FROM USER_DocViews WHERE USERID=S1.ID AND ViewDate BETWEEN #& dtmFrm &# AND #& dtmTo &# GROUP BY USERID) As LastLoginDate,
(SELECT COUNT(*) FROM USER_DocViews WHERE USERID=S1.ID AND ViewDate BETWEEN #& dtmFrm &# AND #& dtmTo &# GROUP BY USERID) As DocsSeen

FROM USER_INFO S1

WHERE S1.ID=ANY (SELECT USERID FROM USER_DocViews WHERE ViewDate BETWEEN #& dtmFrm &# AND #& dtmTo &#);

When I try to use the "ORDER BY DocsSeen" or "ORDER BY LastLoginDate" I either get errors or the data is not sorted correctly. Help!

   

- Advertisement -