现在需要做一个用户投稿每月排名,有两个表:用户表 user 字段有ID、username 文章表和用户表关联的字段是Inputer,我的写法是:
sql = "select User_Name,(select count(ID) from Article where DateDiff('m',addtime,now())=0 and Inputer=User_Name) as total from User group by User_Name order by total desc"
运行后提示错误:错误 '80040e10' 至少一个参数没有被指定值。 如果不加order by total desc,同运行正常,但却不是按照投稿数量排名。
...全文
4842打赏收藏
统计结果并排序
现在需要做一个用户投稿每月排名,有两个表:用户表 user 字段有ID、username 文章表和用户表关联的字段是Inputer,我的写法是: sql = "select User_Name,(select count(ID) from Article where DateDiff('m',addtime,now())=0 and Inputer=User_Name) as total from User group by User_Name order by total desc" 运行后提
select User_Name,count(User_Name) as total
from User inner join Article on Inputer=User_Name
where DateDiff('m',addtime,now())=0
group by User_Name
order by count(id) desc
这样试试