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 |
|
avmreddy17
Posting Yak Master
180 Posts |
Posted - 2008-03-03 : 14:04:08
|
| Can some one help me rewriting the Qry so that I get TOP 10 rows from the cNumbers table for each branchCodeExternal SELECT * FROM ConfigDB..cNumbers WHERE BranchCodeInternal IN ( SELECT BranchCodeInternal FROM ConfigDB..CTSBranches WHERE BranchCodeExternal IN ( '001','129','162'))ORDER BY BranchCodeInternalThx |
|
|
avmreddy17
Posting Yak Master
180 Posts |
Posted - 2008-03-03 : 14:26:02
|
| Thanks..I guess I got it... If there is more easy way of wring this..pls reply.. Thanks for any helpSelect BranchCodeInternal , cNumberExternalFrom ConfigDB..cNumbers as t1Where (Select count(distinct cNumberExternal) from ConfigDB..cNumbers Where BranchCodeInternal = t1.BranchCodeInternal and cNumberExternal >= t1.cNumberExternal)<=10 AND BranchCodeInternal IN ( SELECT BranchCodeInternal FROM ConfigDB..CTSBranches WHERE BranchCodeExternal IN ( '001','129','162'))Order By BranchCodeInternal, cNumberExternal |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
|
avmreddy17
Posting Yak Master
180 Posts |
Posted - 2008-03-03 : 14:46:12
|
| using SQL Server 2000 |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
|
|
|
|
|