SQL Server Performance

temp table vs ????

Discussion in 'T-SQL Performance Tuning for Developers' started by pithhelmet, Feb 6, 2003.

  1. pithhelmet New Member

    Hi All -

    Here is my scenerio -

    I have a table that has many columns, but one in particular
    is causing my concerns -

    it is a float type - and the floor manager asked me to assign a group id to this number via a range he has made up -

    for instance -
    slow group = 0 - 18.5
    med group = 19 - 24.9
    fast group = 25 - 29.9
    super group = 30 - 34.9
    stellar group = 35 - 39.9
    top group = > 40.0

    I cannot add another field into the database, and have the stored proc fill in the grouping as it is posted - so thats out of the question -

    so i was thinking about creating a temp table, and using a two column setup (one is the unique id, the second would be the group)

    but i'm having concerns on this - does anyone have an alternate solution???

    thanks
    tony

  2. trifunk New Member

    I might be off track here but if you have a seperate table holding the group for a specific record, if you ever altered the range of a group wouldn't your table would become incorrect?

    If you want to query which group a record is in you could try a CASE statement with the ranges for the group in in a stored proc, I'm not sure how politically correct this is for a developer but it would be an easy implementation although maybe not a sound one.

    Cheers
    Shaun



    World Domination Through Superior Software
  3. Chappy New Member

    Other options would be to have a UDF which given a score returns the group ID.
    Another idea is a table of the form

    GroupID (int primary key)
    High (float)
    Low (float)

    And then you could join this table onto your main table to get the group ID. Im like trifunk in that I could not comment on how efficient this would be, but I think the lookup table would be the first avenue id try.

Share This Page