I was feeling charitable this morning so I created the ddl and sample data to work with.
if OBJECT_ID('tempdb..#Data') is not null
drop table #Data
create table #Data
(
MyName varchar(20),
Age int,
Salary int,
Department varchar(20)
)
insert #Data
select 'SHARATH', 24, 21000, 'MARKETING' union all
select 'RATHAN', 35, 21000, 'MARKETING' union all
select 'RATS', 28, 21000, 'IT' union all
select 'DARSHAN', 23, 20000, 'IT' union all
select 'LINI', 25, 25000, 'IT' union all
select 'SHAN', 23, 20000, 'MARKETING' union all
select 'SUDARSHAN', 22, 20000, 'IT'
select * from #Data
If the OP can confirm this will work we can figure out what they want as output and proceed from there.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/