MS SQL order by

Is it possible to do a MS SQL query where the order by is the sum of two fields?

If I have two numeric fields in the table and want the query to sort by the sum of those fields.
cdjohn31Asked:
Who is Participating?
 
Carl TawnConnect With a Mentor Systems and Integration DeveloperCommented:
Yes, you can do something like:
SELECT Value1, Value2, [Stuff] FROM SampleTable ORDER BY Value1+Value2

Open in new window

0
 
CluskittCommented:
Yes, you can. The sum of two fields is, as far as SQL is concerned, just a field. It is calculated from 2 others, but it's computed as if it's a field like any other.
0
 
Pratima PharandeCommented:
ye you can like this
select col1,col2,(col1 +col2) as sumofcol from tablename
order by (col1 +col2)
0
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.

All Courses

From novice to tech pro — start learning today.