January 20, 2011 at 9:33 am
Hi,
i Have small requirement to convert multiple rows into 1 row
the input is as folllows
and the output i need as follows
key points: premium should be sum off all for each indidiual record,
Thanks in Advance
ANjee
January 20, 2011 at 9:37 am
what rows are you trying to combine and as far as the sum it is
SELECT ItemName, SUM (Item2) AS "OutPut Name"
From...
January 20, 2011 at 9:39 am
Hi Thanks for your reply,
i'm trying to combine rows with same last name and first name.
Thanks
Anjee
January 20, 2011 at 9:43 am
You can use the GROUP BY for thous
Select *
From TableName
Group By FirstName,LastName
Or how ever you have the name of the columns =)
January 20, 2011 at 10:01 am
i think you understood my requirement corrrectly.
there are two tables
image 1:shows input
image 2 :output.
January 20, 2011 at 10:10 am
There is no direct single T-SQL code that can do this requirement, but u still have a cool code to do it. Please go thro this fantastic article from our Jeff Moden
The concept : Dynamic Cross Tabs
The Link : http://www.sqlservercentral.com/articles/Crosstab/65048/
January 20, 2011 at 11:20 am
If the colum names are the same that you want to combine you can use UNION
Select ColumnA,ColumnB,ColumnC
From TableA
Union
Select ColumnA,ColumnB,ColumnC
From TableB
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply