sql - 单列上的多个条件以将数据返回到多列
问题描述
我有一个查询,检索大约 60 多列,其中列名“资格”(sslc、hsc、文凭)及其各自的分数(“Sslc 分数”、“Hsc 分数百分比”、“文凭”)已在不同的行中检索到每个候选人。
例如。候选人“X”具有“hsc”资格,然后候选人“x”将在两行中检索,其中 sslc 标记为一列,hsc 标记百分比在另一列
但是需要将数据检索为,每个候选人在同一行中针对他们各自的资格标记
现有查询供参考 -
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
解决方案
推荐阅读
- azure - Azure 虚拟机阻止对除 vnet 之外的端口的所有访问
- security - 您可以使用图像之类的东西来对某人进行 ip 登录,而无需他们单击链接吗?(阅读下面发生的事情)
- java - Find Integer in Array - 使用函数式编程简化解决方案
- php - 验证后避免 Laravel 重定向
- pyspark - 使用 AWS GLue Pyspark 在 Redshift 中实施 SCD2
- cryptography - 为了防止重放攻击,我应该什么时候接受和拒绝时间戳?
- c++ - 函数式转换指针
- histogram - 从 csv 文件绘制直方图
- javascript - 如何在 vuejs 中从菜单中单击动态路由时从 li 中获取值?
- kubernetes - 在组名中发现无效字符但未替换 ansible k8s