December 4, 2015 at 2:07 pm
Hello,
I have a query where I am trying to get only the first record for a field that has the same value for multiple records. I am using Row_Number OVER(), and the query is working fine but it displays the Row number column in the result set. How do I avoid displaying that row number column?
Thanks.
December 4, 2015 at 2:38 pm
I have resolved the issue.
December 4, 2015 at 3:15 pm
ramadesai108 (12/4/2015)
I have resolved the issue.
It may be of interest to other forum members to know how you solved your problem. I'm guessing you did something like
With (your original query) as rws
Select cols
From rws
Or did you find another way?
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
December 4, 2015 at 3:34 pm
A SELECT TOP 1...ORDER BY would also do the trick.
December 5, 2015 at 8:46 pm
ramadesai108 (12/4/2015)
I have resolved the issue.
Cool! Please post your solution.
--Jeff Moden
Change is inevitable... Change for the better is not.
December 7, 2015 at 3:53 am
Ed Wagner (12/4/2015)
A SELECT TOP 1...ORDER BY would also do the trick.
Not necessarily. RowNumber can do grouping, and so return one row per partition. Top 1 is just top 1.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
December 8, 2015 at 5:40 am
GilaMonster (12/7/2015)
Ed Wagner (12/4/2015)
A SELECT TOP 1...ORDER BY would also do the trick.Not necessarily. RowNumber can do grouping, and so return one row per partition. Top 1 is just top 1.
Touche.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply