Sql server selection

Please find attachment , its sample data and table.

How to get out put like following

output.PNGPlease find output file for format.  

what is the qurey for it
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PortletPaulEE Topic AdvisorCommented:
there is no attachment
PortletPaulEE Topic AdvisorCommented:
without the attachment: I believe the query will look something like this

     , max(a) as a
     , max(b) as b
     , max(c) as c
     , max(d) as d
     , max(e) as e
     , max(f) as f
from your_table
Vikas GargAssociate Principal EngineerCommented:

You can do this

Select main, 
	   sum(isnull(a,0)) as a
     , sum(isnull(b,0)) as b
     , sum(isnull(c,0)) as c
     , sum(isnull(d,0)) as d
     , sum(isnull(e,0)) as e
     , sum(isnull(f,0)) as f
from Table

Open in new window

codeoxygenAuthor Commented:
PortletPaul ,
 Attached files are , embedded. the two images your able to see.

above query is ok but if a column as you values then i need both values with coma (,) as separation.

who to achieve it.
PortletPaulEE Topic AdvisorCommented:
>>"but if a column as you values then i need both values with coma (,) as separation. "

You only want 2 columns in the expected result? Like this?

Main    The_Others
Main1  1,2,5
Main2  3,4

Please provide your existing query.
(The one that produced the first image in your question.)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.