Hi everyone I need help with sql select statement.I have table and in that table some columns have same value like: John 23 Smith 36 Suzan 21 John 12 and I don't know how to write select statement that would add columns with same name and select the other columns too.The result should be John 35 Smith 36 Suzan 21 Please help. Thanks in advance
You need to use GROUP BY clause.. check this script declare @tab table (name varchar(20), amt int)insert @tab select 'John', 23insert @tab select 'Smith', 36insert @tab select 'Suzan', 21insert @tab select 'John', 12select name,sum(amt) as sumamt from @tab group by Name