find top 50 values from 90% records of table.

  • Hi friends,

    I am having a table that contains 100000.these are log file.among this depending upon fastest responce i have to find 90% records i.e. 900000 first and among this top 50 i have to display.

    regards

    Abhas.

  • what have you tried so far?

    SQL supports the TOP command, ie

    --last 90 days of data

    SELECT TOP 50 ColumnList From MyLogTable Where SomeDate > dateadd(dd,-90,getdate())

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • abhas (2/10/2011)


    Hi friends,

    I am having a table that contains 100000.these are log file.among this depending upon fastest responce i have to find 90% records i.e. 900000 first and among this top 50 i have to display.

    regards

    Abhas.

    This almost sounds like an interview question which is trying to figure out how you think.

    Using a bit of Boolean logic, I'd normally say that means you only need to find the top 50 rows. However, your 90% requirement may be based on something else. Is the 90% requirement based on ANY top 90% or is there some criteria which must be met first?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Thank u Lowell

    But i need avarage upon time not on date.and time is in miliseconds.So i have to find largest 90% avarage from table.How can we do?

    Regards

    Abhas.

  • abhas (2/21/2011)


    Thank u Lowell

    But i need avarage upon time not on date.and time is in miliseconds.So i have to find largest 90% avarage from table.How can we do?

    Regards

    Abhas.

    details. show us a query that has the columns and tablenames.

    show us what youve tried so far.

    define the 90% group. 90% of what? peanut butter?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply