我一直在网页上对SQL结果进行一些排序,但这些排序还没有完全正常。当我按计数对结果进行排序时,会出现某种断开连接。任何人都可以看到任何明显的原因吗?
此查询按员工ID分组计数:
SELECT userid, username, COUNT(DISTINCT maintlist.maintid) as thecount
from Userlist inner join maintlist ON MaintList.enteredby = convert(varchar(20),userid)
inner join maintnotes on maintnotes.maintid = maintlist.maintid
where deptnum <> '0' AND notedate between '2015-10-01' AND '11/1/2015'
group by userid, username order by thecount DESC;
此查询在获取每个员工ID后运行:
(第一名员工被查询)
strSQL = "SELECT userid, username from Userlist where deptnum <> '0' order by "&sorton&" "&sortonorder&";"
然后执行计数查询:
SELECT COUNT(DISTINCT maintlist.maintid)
FROM [Maint].[dbo].[MaintNotes] inner join maintlist ON MaintList.maintid = maintnotes.maintid
WHERE maintnotes.enteredby = '143'
AND notedate between '2015-10-01' AND '11/1/2015';
每个ID的号码都已关闭,但我不确定断开连接的位置? 谢谢!