Easiest way to find Minimum value of each row and find sum of each row in sql server
If you have a table with many column and you want to find minimum value of each row or you want to find sum of each row then this is very helpful and easy way to you.
Lets starts by going through sample code.
For example you have a table like
NAME C1 C2 C3
A 10 15 5
B 30 20 40
C 50 70 60
//For finding sum of each row of table
Select * from Table1
select
[Name],
[RowSum]= (select Sum(value) from (select C1 union all select C2 union all select C3) X(value))
from table1
//For finding Minimum value of each row of table
Select * from Table1
select [Name], [MinRowValue]= (select Min(value) from (select C1 union all select C2 union all select C3) X(value))
from table1
//REsult of Queryies
Then Result for Sum of each Row is
NAME SUM
A 30
B 90
C 180
And Min Value result is
NAME MinRowValue
A 5
B 20
C 50
//this result is Appears from This Table
Table1
NAME C1 C2 C3
A 10 15 5
B 30 20 40
C 50 70 60
this part of helps you to find Tables with out indexes
//List of all Tables without Indexes in MS SQL
How to get the list of all tables that are not having any indexes on them :
Today, I got a question on this and decided to put the way here also.
//Query is
SELECT [name] AS Tables_Without_Indexes FROM sys.tables
WHERE OBJECTPROPERTY(OBJECT_ID,'IsIndexed') = 0
ORDER BY 1;
The above statement will give the tables that are not having any indexes..
hi,
this article is useful for me,
i am searching this problem, my problem have solve now.
Dharmendra