How to implement rows per group in Select SQL statement

Last Post 25 Mar 2009 04:58 AM by shankardotnet. 0 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
shankardotnet
New Member
New Member

--
25 Mar 2009 04:58 AM
How to implement dynamic rows per group in Select SQL statment. i need to pass number of rows per group as parameter to storeprocedure.
Out of 10 rows , 4 + 4 + 2 rows to display. it just a split of same group in select statement
Out of 9 rows , 4 + 4 + 1 rows to display. it just a split of same group in select statement
if number of rows per group =four then 4 rows per group.Output looks as follows
Country LastName FirstName ShippedDate OrderID SaleAmount
UK
Buchanan--------Steven----00:00.0-------10254---556.62
Dodsworth-------Anne------00:00.0-------10255---2490.5
Buchanan--------Steven----00:00.0-------10248---440
Suyama----------Michael---00:00.0-------10249---1863.4
UK
Dodsworth-------Anne------00:00.0-------10263---1873.8
Suyama----------Michael---00:00.0-------10264---695.63
King------------Robert----00:00.0-------11047---817.88
King------------Robert----00:00.0-------11048---525
UK
King------------Robert----00:00.0-------11066---928.75
King------------Robert----NULL----------11074---232.09
USA
Callahan--------Laura-----NULL----------11075---498.1
Peacock---------Margaret--NULL----------11076---792.75
Davolio---------Nancy-----NULL----------11077---1255.72
Davolio---------Nancy-----00:00.0-------11067---86.85
USA
Callahan--------Laura-----NULL----------11068---2027.08
Davolio---------Nancy-----00:00.0-------11069---360
Fuller----------Andrew----NULL----------11070---1629.97
Davolio---------Nancy-----NULL----------11071---484.5
USA
Peacock---------Margaret--NULL----------11061---510

Thanks in Advance
Report post as abusive


Acceptable Use Policy
---