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 |
satheesh
Posting Yak Master
152 Posts |
Posted - 2013-07-30 : 05:38:39
|
Hi All,I want to show the number of rows returned by a select query in the result.e.g. select policy,policynumber,datecreated,Firstname, '-' as recordcount from policy If it returns 5 rows, then the 'recordcount' need to show '5' in all row in the resultOutPut0y96788,HGYG564,29/07/2013,SAM,5FJUFBN7,JLPIO67,29/07/2013,Test,5.......How can i get this number in the result.Any help will be highly appreciated.ThanksRegards,SG |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-07-30 : 06:26:03
|
[code]select policy,policynumber,datecreated,Firstname, COUNT(*) OVER() as recordcount from policy [/code]You might want to use a PARTITION BY clause in the OVER() construct if you want to group the count. |
|
|
satheesh
Posting Yak Master
152 Posts |
Posted - 2013-07-30 : 06:44:55
|
Thanks James. Its working. |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-07-30 : 08:28:02
|
You are very welcome - glad to help. |
|
|
|
|
|
|
|