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
 General SQL Server Forums
 New to SQL Server Programming
 select query - sql server 2005

Author  Topic 

paramu
Posting Yak Master

151 Posts

Posted - 2009-07-02 : 02:15:29
I have a select Query, but I want to add the row-number as serial_number, is it possible?

select row_number??? as sl_no,mprmst.mpr_no,mprmst.itm_code,itemmst.itm_description,mprmst.itm_specify,mprmst.Itm_qty from mprmst,itemmst where mprmst.mpr_no='1344' and itemmst.itm_code=mprmst.itm_code

Thanks

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-07-02 : 02:17:36
select row_number() OVER(order by mpr_no) as sl_no,mprmst.mpr_no,mprmst.itm_code,itemmst.itm_description,mprmst.itm_specify,
mprmst.Itm_qty from mprmst,itemmst where mprmst.mpr_no='1344' and itemmst.itm_code=mprmst.itm_code
Go to Top of Page

Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2009-07-02 : 02:18:36
Yes it is possible, on what column basis to partition

Eg;-
row_number() over ( partition by column order by column)
Go to Top of Page

paramu
Posting Yak Master

151 Posts

Posted - 2009-07-02 : 05:15:12
Both BKLR & NAGESHWAR are doing good services, Really appreciated

Paramu @ PARANTHAMAN
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-07-02 : 05:19:36
welcome
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-07-02 : 05:46:25
Also refer
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/multipurpose-row-number-function.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -