获取每个客户的前12条记录 [英] fetching top 12 records of each client
本文介绍了获取每个客户的前12条记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在表中具有每个客户端的性能数据
有字段
clientid(varchar(20)),date(datetime),性能(数字)
现在我想要的是,根据他们的表现来获取每位客户的前12条12条记录.
请帮忙..
在此先感谢
I am having performance data of each client in a table
having fields
clientid(varchar(20)),date(datetime), performance (number)
now what I want is, to fetch top 12 twelve record of each client on the basis of their performance.
please help..
thanks in advance
推荐答案
尝试一下:
Try this:
SELECT a.* FROM articles AS a
LEFT JOIN articles AS a2
ON a.section = a2.section AND a.article_date <= a2.article_date
GROUP BY a.article_id
HAVING COUNT(*) <= 12;
经过测试的查询
Tested query
SELECT DISTINCT TOP 12(Clientid), MAX(Performance) AS MAX_PerformanceOfClient FROM [TableName]
GROUP BY Clientid
ORDER BY MAX(Performance) DESC
尝试以下语句
Try this statement
select distinct top 12 (clientid), performance from tableName
Order By performance desc
问候,
T
Regards,
T
这篇关于获取每个客户的前12条记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文