Click here to Skip to main content
15,904,497 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 5-Jun-12 1:20am
v2
Comments
PunithaSabareeswari 5-Jun-12 7:18am    
"select top(10) mobno from Table_name"


It may be used for u...... Use It
taha bahraminezhad Jooneghani 5-Jun-12 8:30am    
for which Scenario?

This will return only distinct phone numbers:
SQL
SELECT DISTINCT TOP 10 User_No FROM  YourTable
ORDER BY id DESC
 
Share this answer
 
Very hard without your schema, but
SQL
select top 10 * from (select distinct * from table order by datecolumn) as t
 
Share this answer
 
Try:
SQL
SELECT TOP 10 * FROM MyTable ORDER BY MyPrimaryKeyID DESC

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.
 
Share this answer
 
Comments
gaurav786mishra 5-Jun-12 7:28am    
i want last ten distinct User_No
Sandeep Mewara 5-Jun-12 9:35am    
Did you follow the answer?

SELECT TOP 10 User_No FROM MyTable ORDER BY User_No DESC
Try this:
SQL
select DISTINCT mobNo
  from (select * from <table name> order by id, date desc) p
 where rownum <= 10  ORDER BY mobNo;


have look on:
Last n records[^]

http://social.msdn.microsoft.com/Forums/en/transactsql/thread/ca7cfd7d-532e-455c-956e-54b95eeb26a8[^]

http://www.sitepoint.com/forums/showthread.php?623264-SQL-Query-to-get-latest-but-unique-records[^]
 
Share this answer
 
SQL
select top 20 user_no from tbl_webservicedata group by user_no order by max(id)desc
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900