Select TOP 0.1 Percent

Lali

New member
Local time
Tomorrow, 03:15
Joined
May 4, 2009
Messages
2
I have a table of 8728 records, but I only want to do calculations for the bottom 99.9%, i.e. I can exclude the top 0.1%
I know I can't use 99.9 or 0.1 in the Select statement as TOP needs to be followed by an INT

So, I have calculated the number of records I want to use
(Round([NOf_East_Jitter]*0.999) AS CNOR which comes to 8719

But how do I put this calculated value into a Select statement?
 
have you tried using the query grid with the following?

Code:
CNOR: (Round([NOf_East_Jitter]*0.999)
note: how have you generated [NOf_east_jitter]?
 
Hi,
My initial query is a make table to store results

SELECT Count(*) AS AllCount, Round(Count*0.999) AS ReportCount, Avg([1RawJitter].[Jitter]) AS AllAvg, 0 AS ReportAvg INTO 2RptJitter
FROM [1RawJitter];

Then I want to do a SELECT TOP (2Jitter.ReportAvg) type query to update 2Jitter.ReportAvg to contain the AVG value of the bottom 99.9% of results. This is where I have problems!
 
I too am looking for a top / bottom select statement to show the last number of records similiar to what mysql has. I always can do it through programming but would pefer a query.
 
Just for reference:

One possible solution in pure SQL to get 0.1%:

Code:
SELECT TOP 10 PERCENT * FROM
(SELECT TOP 1 PERCENT * FROM sometable) t;

Not so efficient. An alternative syntax is to take advantage of the autonumber:
Code:
SELECT * FROM 
sometable t WHERE 
    (SELECT Count(id) FROM 
    sometable c WHERE c.id <= t.id) 
    = (SELECT 0.01 * Count(id) FROM sometable);

HTH
 
Just for reference:

One possible solution in pure SQL to get 0.1%:

Code:
SELECT TOP 10 PERCENT * FROM
(SELECT TOP 1 PERCENT * FROM sometable) t;
Not so efficient. An alternative syntax is to take advantage of the autonumber:
Code:
SELECT * FROM 
sometable t WHERE 
    (SELECT Count(id) FROM 
    sometable c WHERE c.id <= t.id) 
    = (SELECT 0.01 * Count(id) FROM sometable);
HTH

That second example looks pretty slick.
 

Users who are viewing this thread

Back
Top Bottom