Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 23-02-2009
Member
 
Join Date: Nov 2008
Posts: 85
Row Number in SQL Database

hi there

I am having some query regarding sql.
My Question is that How do I provide a distinct unique number to each field returned. I also want to prefer to do it in sql and not to create an index as the table as I don't have sole control of the table. In the below desired output description this would be RowIndex.

SQL 2000
Statement to add rowindex to:
select distinct(Description) as LawSpecialty from lawspecialty

Please help me in this sql qeury
Reply With Quote
  #2  
Old 23-02-2009
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: Row Number in SQL Database

select * from (

SELECT a.Description,
Id = ( SELECT COUNT(1) FROM (SELECT DISTINCT(Description) FROM LawSpecialty ) b WHERE a.Description > b.Description ) +1
FROM (SELECT DISTINCT(Description) FROM LawSpecialty ) A
) C
where id in (1,2,3)
Reply With Quote
  #3  
Old 23-02-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: Row Number in SQL Database

ELECT ROW_NUMBER()
OVER (ORDER BY EmployeeName) AS Row,
EmployeeId, EmployeeName, Salary
FROM Employees

which will provide you as output:

Row EmployeeId EmployeeName Salary
-------------------------------------------
1 1002 Alden 4000
2 2343 Lawson 4500
3 2004 Barbra 4800
4 1105 Marsden 4500
5 3116 Mac 5000
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Row Number in SQL Database"
Thread Thread Starter Forum Replies Last Post
How to change the number to private number in BlackBerry 8520? M@ndy Portable Devices 3 30-01-2012 06:01 PM
Should I buy US number or European number hp ink cartridge for HP printer 5160? Kash123 Hardware Peripherals 3 16-09-2011 10:56 AM
Number of Installs reported by Console and the Number of Sales for Paid Apps doesn?t match? PhoebeM Portable Devices 6 16-08-2011 10:51 PM
Vodafone gets the maximum number of users after the mobile number portability Antariksh Portable Devices 5 21-03-2011 10:24 AM
convert filemaker pro database to access database Czack MS Office Support 3 15-04-2007 01:06 AM


All times are GMT +5.5. The time now is 05:03 PM.