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

  • Home
  • SEARCH
  • 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 7848689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:17:35+00:00 2026-06-02T18:17:35+00:00

I have a query that lists features, based on components status and availability SELECT

  • 0

I have a query that lists features, based on components status and availability

SELECT Brand.Id
  , Brand.Name
  , Brand.Impact
  , Brand.Visibility
  , Brand.Risk
  , SUM(Brand.Impact + Brand.Visibility + Brand.Risk) AS Priority

FROM Brand 
LEFT OUTER JOIN Type 
  ON Brand.Id = Type.FeatureId 
LEFT OUTER JOIN Model 
  ON Type.Id = Model.SubFeatureId 
LEFT OUTER JOIN TestingStatus 
  ON Model.StatusId = TestingStatus.Id

WHERE (Model.IsDeleted = 'False') 
  AND (Brand.IsDeleted = 'False') 
  AND (Type.IsDeleted = 'False')
  AND (@TeamId = 0 OR Model.TeamId = @TeamId)
GROUP BY Brand.YearId, Brand.Id, Brand.Name, Brand.Impact, Brand.Visibility, Brand.Risk
HAVING (Brand.YearId = @YearId)

My results are as follow:

ID  Name    Impact  Visibility  Risk    Priority
403 Chevy   1       2           3       48
404 Nissan  1       1           1       24
405 Toyota  3       2           1       42

Instead of

ID  Name    Impact  Visibility  Risk    Priority
403 Chevy   1       2           3       6
404 Nissan  1       1           1       3
405 Toyota  3       2           1       6

Each of these brands have respectively 8, 8 and 7 models. Which means that my query is doing for all of them to calculate priority: Impact*models + Visibility*models + Risk*models.

How can I get my SQL query to not do that multiplication?

Thanks

  • 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-02T18:17:37+00:00Added an answer on June 2, 2026 at 6:17 pm

    Based on your comment and unless I am not understanding what you need, I don’t think you need the SUM(). I think you just want the total for each model. Using the SUM() you are going to get the total for all records which it doesn’t sound like you want. This would also remove your GROUP BY and HAVING

    SELECT Brand.Id
      , Brand.Name
      , Brand.Impact
      , Brand.Visibility
      , Brand.Risk
      , (Brand.Impact + Brand.Visibility + Brand.Risk) AS Priority
    
    FROM Brand 
    LEFT OUTER JOIN Type 
      ON Brand.Id = Type.FeatureId 
    LEFT OUTER JOIN Model 
      ON Type.Id = Model.SubFeatureId 
    LEFT OUTER JOIN TestingStatus 
      ON Model.StatusId = TestingStatus.Id
    
    WHERE (Model.IsDeleted = 'False') 
      AND (Brand.IsDeleted = 'False') 
      AND (Type.IsDeleted = 'False')
      AND (@TeamId = 0 OR Model.TeamId = @TeamId)
      AND (Brand.YearId = @YearId)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that looks like SELECT P.Column1, P.Column2, P.Column3, ... ( SELECT
I have a query that looks a bit like this: SELECT weekEnd, MAX(timeMonday) FROM
I have a query that looks like this: it takes a list of IDs
I am using in C# MYsql .I have query that works if I run
I have a query that I know can be done using a subselect, but
I have a query that updates one record, and only one record. Is there
I have a query that might be executed by several users consecutively. I'm scared
I have a query that shows me a listing of ALL opportunities in one
I have a query that uses a where clause. At times, this may be
I have a query that returns a result set similar to the one below:

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.