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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 add the query sequence number

Author  Topic 

webcakali
Starting Member

16 Posts

Posted - 2011-02-17 : 19:38:21
I would like to add a sequence number myquery

myquery as follows

Select fldKullAdi,fldPuan From tblUyeler
Order By Convert(Decimal(25,2),fldPuan) DESC



here, "Sira" cell including how I myquery

Select fldKullAdi,fldPuan From tblUyeler Where fldKullAdi = 'Mehmet'

When I run the query and then display the output of the above would be as follows




**************************************
Select
fldKullAdi,fldPuan,
ROW_NUMBER() OVER(Order By Convert(Decimal(25,2),fldPuan) DESC) As Sira
From tblUyeler

I get the order number in this way.

but when I took a single record is coming as well as the number 1.

Thank you for helping

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-02-17 : 19:52:33
[code]
; with tbl
as
(
select fldKullAdi,fldPuan, seq = row_number() over (order by fldPuan)
from tblUyeler
)
select *
from tbl
where fldKullAdi = 'Mehmet'
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

webcakali
Starting Member

16 Posts

Posted - 2011-02-17 : 19:54:28
Thank you very much for your help khtan...
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2011-02-18 : 00:04:40
quote:
Originally posted by webcakali

Thank you very much for your help khtan...



Wow..You do really have a wonderful website...

http://www.mehmetsalkim.com/

PBUH

Go to Top of Page
   

- Advertisement -