How to perform row wise math operations in SQL Server? -


how perform row wise math operations in sql server?

eg: want find average of marks particular student shown in table below

student     mark1   mark2   mark3   avg ----------------------------------------------- ram         78       81      56     71.67 jos         92       67      54     71.00 saj         98       91      89     92.67 

select student, mark1, mark2, mark3, 1.0 * (mark1 + mark2 + mark3)/3 avg yourtable 

add 1.0 * convert sum result float before division


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -