top-n query, what is, how done?

top-n query, what is, how done?

Post by Rene Nyffenegge » Sun, 31 Dec 1899 09:00:00



Hi

In another thred on c.db.or.m, I read about top-n queries.
Obviously, it's intended to get the top n of something.
But how would I formulate such a query?

TIA
Rene

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

1. Query performance issue - What Am I doing wrong?

IN tblTrans i have a group of transactions that all come under the same
FileName.  I have created a query to extract all the distinct file names
into tblFiles to create FileID's for each file.  I then run a query to Join
tblFiles to tblTrans so that I will list a FileID and the Transaction
INformation.
----
SELECT tf.FileID, edi.* from tblTrans edi
JOIN tblFiles tf ON tf.FileName = edi.FileName
----

tblTrans will have 70K rows, tblFile will have about 1.7K rows after I run
the extract query.

That JOIN query Runs SLOW and it kills my client machine for some reason.
Unlike other queries, this particular query kinda spits out chunks of  data
and will not complete after 15K rows in the tblTrans.  What am I doing
wrong?

I have added an index to tblTrans.FileName  ? Right direction?  Thanks.

CREATE TABLE tblTrans(
TransactionID int NOT NULL,
something1 varchar(15) NULL,
something2 varchar(15) NULL,
something3 varchar(15) NULL,
FileName varchar(64) NOT NULL
)

CREATE TABLE tblFiles(
FileID IDENTITY Int NOT NULL,
FileName varchar(64) NOT NULL
)

--

[Shaun Farrugia] ## [Programmer] ##  [DTE Energy Operations]

o_O

2. Good sites to read about DB Theory?

3. What am I doing wrong (Queries Paradox 7)?

4. Web: "Database not open" - but it IS

5. What am I forgetting or doing wrong

6. syb_sendmsg() function

7. Am I doing this the best way?

8. Invisible tables in :priv:

9. what am I doing wrong in this procedure?

10. TSQL question - what am I doing wrong?

11. what am i doing wrong?

12. Am I doing this correctly?

13. Simple one what am i doing wrong