SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Distinct record
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ersantosh1
Starting Member

India
6 Posts

Posted - 10/08/2012 :  06:39:38  Show Profile  Reply with Quote
i have data in table like:-

A B_name C_REM D_s_id E_Z_id F_time
1 XX YY 12345 7890 12:30:30
2 XX YY 12345 7890 12:30:30
3 XX YY 88888 2222 12:30:30
4 XX YY 88888 2222 12:30:30

i record 1 and 3 record by distinct them as D_s_id and E_Z_ID

plz help

thanks
santosh

srahangdale

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 10/08/2012 :  06:48:02  Show Profile  Reply with Quote
SELECT * FROM 
(
	SELECT *,
		ROW_NUMBER() OVER (PARTITION BY D_s_id,E_Z_id ORDER BY A DESC) AS RN
	FROM
		YourTable
) s
WHERE RN=1

Edited by - sunitabeck on 10/08/2012 06:48:20
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000