本文介绍了sql查询从列中查找最后十个DISTINCT手机号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以帮我找到:
sql查询可从列中查找最后十个DISTINCT手机号码.
我的架构有3列ID,User_No,当前日期.
我想要最后10个不同的手机号码,并将它们显示在数据列表中.

can someone help me to find :
sql query to find last ten DISTINCT mobile numbers from column.
my schema has 3 columns id,User_No,Current Date.
i want last 10 distinct mobile numbers and show them in data list

推荐答案

SELECT DISTINCT TOP 10 User_No FROM  YourTable
ORDER BY id DESC


select top 10 * from (select distinct * from table order by datecolumn) as t


SELECT TOP 10 * FROM MyTable ORDER BY MyPrimaryKeyID DESC


如果您有插入的datetime列,请使用该列进行排序.逻辑是根据序列排序,然后获得前10行.


If you have a datetime column of insertion then use that for sorting. Logic is to sort based on a sequence and then get top 10 rows.


这篇关于sql查询从列中查找最后十个DISTINCT手机号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-26 20:33