Selecting The Top 3 Numbers Used The Most

  • OK, can you do the following please?

    Run (remove the WITH TIES):

    ALTER VIEW NumberView AS

    SELECT TOP 3

    numberValue,

    numberTimesUsed

    FROM number

    ORDER BY numberTimesUsed DESC

    Send the results of the following:

    select * from number

  • Hey Hey, SSC Veteran

    I finally got it working, Thanks SSC Veteran,

    The Problem was That I never had any values for the NumberTimesUsed Column :hehe::hehe:

    But Once It has This script works

    CREATE /*CREATE*/ VIEW NumberView AS

    SELECT TOP 3 WITH TIES

    numberValue,

    numberTimesUsed

    FROM number

    ORDER BY numberTimesUsed DESC

    Thanx :P:P

  • No problem.

    Regards,

    Lian 😎

  • Lian Pretorius (8/12/2008)


    karthikeyan (8/12/2008)


    Hey Trevor,

    I have tested the below script, It is giving perfect result.

    Same here.

    Trevor, Karthik's script above uses a temp table - Which cannot be used in view's definitions.

    The temporary table is not part of the solution... it's just a test setup. 😉

    --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)

  • Lian Pretorius (8/12/2008)

    --------------------------------------------------------------------------------

    karthikeyan (8/12/2008)

    --------------------------------------------------------------------------------

    Hey Trevor,

    I have tested the below script, It is giving perfect result.

    Same here.

    Trevor, Karthik's script above uses a temp table - Which cannot be used in view's definitions.

    The temporary table is not part of the solution... it's just a test setup. 😉

    Jeff,

    I used temporary table just to explain him that my query was working correctly. Thats it.

    But as you said i do agree your point.

    karthik

Viewing 5 posts - 16 through 20 (of 20 total)

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