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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-04-05 : 08:06:05
|
| Raghu writes "Hi, I have a table "tblFiles" with two fields "FileID" and "FileName". There are 100 Records. 5 sets of 20 records have the same fileid. For example FileID = 1 will have 20 different filenames. FileID 2 will have 20 different filenames. I want a result of 3 records per file id. How will I get it?Thanks for help." |
|
|
Jay99
468 Posts |
Posted - 2002-04-05 : 09:21:58
|
maybe somethingcreate table <temptablename><tabledef>insert <tempateblename>select top 3from tblFileswhere FileID = 1insert <tempateblename>select top 3from tblFileswhere FileID = 2insert <tempateblename>select top 3from tblFileswhere FileID = 3 Jay<O> |
 |
|
|
chadmat
The Chadinator
1974 Posts |
Posted - 2002-04-05 : 21:59:26
|
Or if you just want to qury without the temp table:select top 3from tblFileswhere FileID = 1UNIONselect top 3from tblFileswhere FileID = 2UNIONselect top 3from tblFileswhere FileID = 3 -Chad |
 |
|
|
|
|
|