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.
Author |
Topic |
Pasi
Posting Yak Master
166 Posts |
Posted - 2014-02-11 : 14:51:17
|
HI,I am trying to print row numbers in my output report how can I do this? here is my store procedure:Thanks.PasiASBEGINselect distinct group_name,mstr_list_item_desc,person_nbr,cpt4_code_id,p.person_id, p.last_name, p.first_namefrom person pinner join person_payer pp on pp.person_id =p.person_id |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-02-11 : 14:59:58
|
Check out the ROW_NUMBER() function.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
 |
|
Pasi
Posting Yak Master
166 Posts |
Posted - 2014-02-11 : 16:11:12
|
Didn't see any relevant post there? |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-02-11 : 16:21:12
|
Google it or look it up in Books Online.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
 |
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2014-02-12 : 04:26:04
|
how about select @@rowcount? |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2014-02-12 : 12:09:31
|
How does @@rowcount help add numbers to each row without adding a bunch of unnecessary code?Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
 |
|
alexsts
Starting Member
13 Posts |
Posted - 2014-02-12 : 13:39:22
|
quote: Originally posted by Pasi Didn't see any relevant post there?
How do you form your report?If you have loop anywhere to display results from that select you can easily add new column with value id=id+1.If you have it in Crystal then it will take for you new function to represent count for the row.To see some code of how you use result set to display data would be helpful to answer your question.Alex |
 |
|
maunishq
Yak Posting Veteran
71 Posts |
Posted - 2014-02-12 : 14:54:13
|
ROW_NUMBER() OVER (PARTITION BY group_name ORDER BY order_list) |
 |
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2014-02-12 : 20:32:15
|
ooo, see wrongly, i thought OP want the total number of record. |
 |
|
|
|
|