Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to get distinct row when use together with ROW_NUMBER()?

Posted on 2011-03-15
4
Medium Priority
?
513 Views
Last Modified: 2012-08-14
I try to get a list of distinct name from the query below:

Select distinct [rodnee_WISDAssetsInvRemedy].[CI_NAME], ROW_NUMBER() OVER ( Order By [rodnee_WISDAssetsInvRemedy].[CI_NAME] Asc  ) as 'RowNum'
FROM rodnee_WISDAssetsInvRemedy

but it only gave me duplicated names.
104LMWC                      1
104LMWC                      2
ADMHXP01      3
ADMHXP01      4
AIBSFIBCPAPP1      5
AIBSFIBCPAPP1      6
AIBSFIPRODAPP1      7
AIBSFIPRODAPP1      8
AIBSFIUATAPP1      9
AIBSFIUATAPP1      10

Very appreciated for your help!!!
0
Comment
Question by:jssong2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 5

Expert Comment

by:KGNickl
ID: 35141102
I believe its returning unique combinations of both name and row number.
0
 
LVL 9

Expert Comment

by:joshbula
ID: 35141237
SELECT (Select distinct [rodnee_WISDAssetsInvRemedy].[CI_NAME],
FROM rodnee_WISDAssetsInvRemedy ) As CI_NAME, Row_Number(), OVER ( Order By [rodnee_WISDAssetsInvRemedy].[CI_NAME] Asc  ) as 'RowNum',
0
 
LVL 32

Accepted Solution

by:
Ephraim Wangoya earned 2000 total points
ID: 35141297
why not simply

Select [rodnee_WISDAssetsInvRemedy].[CI_NAME], ROW_NUMBER() OVER ( Order By [rodnee_WISDAssetsInvRemedy].[CI_NAME] Asc  ) as 'RowNum'
FROM rodnee_WISDAssetsInvRemedy
group by [rodnee_WISDAssetsInvRemedy].[CI_NAME]
0
 

Author Closing Comment

by:jssong2000
ID: 35141590
Thank you very much!!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

662 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question