Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have table
srno  uni_name  director  contyname  uni_id  org_id  mou_sing  pro_mous  numberofstudent
101    IIT         sanjay    Norway     91      04      yes       No          5
101    IIT         sanjay    Finland    91      04      No        Yes         3


now i want a query which produce this result


srno  uni_name  director            Norway                  Finland            numberofstudent
101     IIT       sanjay     value of mou_sign(yes)   value of mou_sign(yes)      5 , 3


and my query is without pivoting :-

SQL
SELECT ROW_NUMBER() over(order by reg_no)as srno,(svi.reg_no)as reg_no, 
(university_info.university_name) as university_name,
(svi.directors) as vc_dir_name,
(svi.university_id) as uni_id,
 (svi.organization_id) as org_id, 
 (country_info.country_name) as country_name,
(svi.country_code) as conty_code,
(case when svi.mous_signed = '0' then 'Yes' else 'No' end) as mou_singed,  
(svi.number_student) as number_student, 
(case when svi.prop_mous = '0' then 'Yes' else 'No' end) as prop_mous, 
(case when svi.if_prop_mous = '0' then 'Yes' else 'No' end) as if_prop_mous, 
(svi.number_mous) as number_mous ,
(organization.organization_type) as organization_type

FROM state_visit_info svi INNER JOIN
country_info ON svi.country_code = country_info.country_code INNER JOIN
university_info ON svi.university_id = university_info.university_id INNER JOIN
organization ON svi.organization_id = organization.organization_id
where svi.organization_id='04'


[edit]Code block added - OriginalGriff[/edit]
Posted
Updated 28-May-14 1:11am
v5
Comments
CHill60 28-May-14 6:56am    
And what does your query return?

Hello Sanjay,

Please see the following link:
Convert row data to column in SQL Server[^]
 
Share this answer
 
What database are you using?
If it's oracle you can use ListAgg[^], if you're using SQL Server you can take a look at this[^] tip.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900