Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7957385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:14:32+00:00 2026-06-04T04:14:32+00:00

I am doing a query where I need to strip out some lower-level results

  • 0

I am doing a query where I need to strip out some lower-level results using the Max command in SQL Server. How can I then make a higher level Group By statement? I know I can use a temp table for this. I expect high volume and want to avoid creating and destroying the temp table for performance purposes.

SELECT k.Result_ID, k.Key_Name, max(k.Value_Percentage) as Percentage 
FROM Key_Word k
LEFT JOIN Phrase p 
    ON p.Result_ID = k.Result_ID 
    AND p.Key_Name = k.Key_Name 
    AND k.Phrase_Flag = 1
    AND  @fulltextsearch LIKE '%' + p.phrase + '%'
WHERE k.Key_Word IN 
    ('estimated', 'flow', 'cash', 'approximate', 'brian', 'go', 'store') 
    AND (k.Phrase_Flag = 0 OR p.Phrase IS NOT NULL)
GROUP BY k.Result_ID, k.Key_Name
ORDER BY k.Result_ID ASC;

Thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:14:33+00:00Added an answer on June 4, 2026 at 4:14 am

    Are you looking for HAVING ?:

    SELECT k.Result_ID, k.Key_Name, max(k.Value_Percentage) as Percentage 
    FROM Key_Word k
    LEFT JOIN Phrase p 
    ON p.Result_ID = k.Result_ID 
    AND p.Key_Name = k.Key_Name 
    AND k.Phrase_Flag = 1
    AND  @fulltextsearch LIKE '%' + p.phrase + '%'
    WHERE k.Key_Word IN 
    ('estimated', 'flow', 'cash', 'approximate', 'brian', 'go', 'store') 
    AND (k.Phrase_Flag = 0 OR p.Phrase IS NOT NULL)
    GROUP BY k.Result_ID, k.Key_Name
    HAVING max(k.Value_Percentage) > 10
    

    Or if you need to you want to show max(k.Value_Percentage) per Result_ID , you can
    use WITH ROLLUP

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using SQL Server manager 2008. I have a query as follows: SELECT dbo.iLines.Part,
I'm doing an insert query where most of many columns would need to be
I am doing a query to a db using Entity Framework, with this result
How would I go about doing a query that returns results of all rows
Doing a mysqli query and COUNTing the results, is there a preferred comparison operator
I'm having scenario to which a sql query need to be built. I tried
I am doing a query which fetches two fields. I need each of those
I have a question about doing a query through a few associations using Ruby
I am doing SQL query in ASP page, and getting a 100 rows and
I am doing the following query on an XDocument . The last level .Descendants(Instance)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.