Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

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

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 group by?
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kt
Yak Posting Veteran

87 Posts

Posted - 08/22/2014 :  15:34:21  Show Profile  Reply with Quote
Hi,

the results I have is

rank Ord Line DateDel Recpt Item Sup
---- ----- ------ ------ ----- ---- ------
1 ABC 10 2014-04-23 C041804 zzz 123
2 DEF 80 2014-04-14 M041258 zzz 123
2 GHI 40 2014-04-14 K041844 zzz 123

I want to get only first two because last two it has the same date of 2014-04-14, what can I do?

thanks
kt

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 08/22/2014 :  16:25:08  Show Profile  Reply with Quote
SELECT * FROM 
(
	SELECT
		*,
		ROW_NUMBER() OVER (PARTITION BY DateDel ORDER BY Ord) AS RN
	FROM
	(
		YourOriginal Query here
	) s1
) s2 WHERE RN = 1;
Go to Top of Page

kt
Yak Posting Veteran

87 Posts

Posted - 08/22/2014 :  16:51:00  Show Profile  Reply with Quote
thanks alot.
Go to Top of Page
  Previous Topic Topic Next 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.04 seconds. Powered By: Snitz Forums 2000