首页 > 解决方案 > 单列上的多个条件以将数据返回到多列

问题描述

我有一个查询,检索大约 60 多列,其中列名“资格”(sslc、hsc、文凭)及其各自的分数(“Sslc 分数”、“Hsc 分数百分比”、“文凭”)已在不同的行中检索到每个候选人。

例如。候选人“X”具有“hsc”资格,然后候选人“x”将在两行中检索,其中 sslc 标记为一列,hsc 标记百分比在另一列

但是需要将数据检索为,每个候选人在同一行中针对他们各自的资格标记

从查询中检索数据的 csv 文件的屏幕截图

模型输出供参考`

现有查询供参考 -

select 
pd.registration_no as "REGISTRATION NUMBER",
(case when edu.education_level_category_id='1' then 'sslc'
      when edu.education_level_category_id='2' then 'hsc' 
      when edu.education_level_category_id='3' then 'diploma' end )"QUALIFICATION",
(CASE WHEN qm.education_level_id='1' THEN qm.aggregate_percentage          
            END ) "SSLC MARKS",
(CASE WHEN qm.education_level_id='2' THEN qm.aggregate_percentage             
            END ) "HSC MARKS PERCENTAGE",
pd.applicant_cred_id as "APP CRED ID",
(CASE WHEN qm.education_level_id='1' THEN qm.certificate_number            
            END ) "SSLC SNO",
(CASE WHEN qm.education_level_id='3' THEN qm.aggregate_percentage             
            END ) "DIPLOMA",
            



from 
personal_details pd,
additional_details ad,
rps_exam_result res,
applicant_hallticket ah,
phase2_admit_card admit,
caste_category_master caste,
education_level_category edu,
qualification_master qm



where ad.applicant_cred_id=pd.applicant_cred_id
and
ah.applicant_cred_id=pd.applicant_cred_id
and
res.fk_hall_ticket_number=ah.hallticket_number
and
admit.applicant_credential_id=ad.applicant_cred_id
and 
pd.applicant_cred_id=admit.applicant_credential_id
and
caste.category_id=pd.category_id
and
pd.education_level_category_id=edu.education_level_category_id
and
qm.applicant_cred_id=pd.applicant_cred_id
and
ad.applicant_cred_id=qm.applicant_cred_id



group by
pd.registration_no, 
pd.date_of_birth,
pd.name,
pd.father_name,
pd.mother_name, 
pd.photo_identity_card_number,
pd.emailid_primary,
pd.applicant_cred_id,
pd.age_relaxation,
pd.validity_of_community_certificate,
pd.date_of_issue_community_certificate,
pd.photo_path,
pd.signature_path,
pd.community_certificate_path,
pd.photo_identity_path,
pd.photo_path,
ad.ncc_certificate_type,
ad.ncc_certificate_path,
res.sectioni_marks,
res.sectionii_marks,
res.sectioniii_marks,
res.sectioniv_marks,
res.sectionv_marks,
res.marks_relaxation_availed,
ah.hallticket_number,
admit.phase2_asc,
admit.phase2_test_date,
admit.chest_no,
admit.applicant_phase2_regno,
caste.category_long_code,
edu.education_level_category_id,
qm.aggregate_percentage,
qm.marksheet_path,
qm.certificate_number,
qm.date_of_issue_marksheet,
qm.education_level_id


order by pd.registration_no limit 5

标签: sql

解决方案


推荐阅读