Link to home
Start Free TrialLog in
Avatar of codeoxygen
codeoxygen

asked on

Sql server selection

User generated image
Please find attachment , its sample data and table.

How to get out put like following

User generated imagePlease find output file for format.  

what is the qurey for it
Avatar of PortletPaul
PortletPaul
Flag of Australia image

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

select
       main
     , 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
GROUP BY
       main
Hello,

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
GROUP BY main

Open in new window

Avatar of codeoxygen
codeoxygen

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of PortletPaul
PortletPaul
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial