SQL Server Select to Add column values and then use results in where clause

I need a SQL Server Select that will add up multiple table columns and then use the results in a where clause.

Col1    Col2    Col3   Col4    Col5
100     99.99   4.00   500    4.00
4          0.99     3.33   9.99   10.00

I need to find all the rows with a total value of Col1 - Col5 greater 100.

Select *  where TotalValue > 100
hojohappyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Brian CroweDatabase AdministratorCommented:
SELECT...
FROM myTable
WHERE Col1 + Col2 + Col3 + Col4 + Col5 > 100
0
Scott PletcherSenior DBACommented:
WHERE
    Col1+Col2+Col3+Col4+Col5 > 100

Or:

SELECT ..., TotalValue, ...
FROM dbo.tablename
CROSS APPLY (
    SELECT Col1 + Col2 + Col3 + Col4 + Col5 AS TotalValue
) AS assign_alias
WHERE
    TotalValue > 100
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Guy Hengel [angelIII / a3]Billing EngineerCommented:
You cannot use the expression alias in the where clause (only in the order by)
Either you repeat  the expression, use a subquery/inline query, or you could add that column directly as computed column to the table.
0
Scott PletcherSenior DBACommented:
... or, my preference in this case, use CROSS APPLY to generate the desired alias name.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.