0% found this document useful (0 votes)
7 views4 pages

Queries 5

Uploaded by

reporting.anin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Queries 5

Uploaded by

reporting.anin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

****Get users

select Concat(firstname, " " , lastname) as Name, email as


Email,DATE_FORMAT(FROM_UNIXTIME(timecreated), '%Y-%m-%d %H:%i:%s') AS 'Registerd
Date' , department as Department, "Manager" as Manager, institution as
Organization from soft_user;

****Get users as Mantee and others

select Concat(firstname, " " , lastname) as Name, email as Email,


DATE_FORMAT(FROM_UNIXTIME(timecreated), '%Y-%m-%d %H:%i:%s') AS 'Registerd Date' ,
department as Department, IF(id in (
Select su.id
from soft_user su INNER join soft_cohort_members scm
on su.id = scm.userid
INNER JOIN soft_cohort sco
on scm.cohortid = sco.id where sco.name = 'Mentees'
) ,"Mentee" , "Manager" ) as Manager, institution as Organization from soft_user
where deleted <> 1

**** Grade wise assigned course to user

Select
usercoursedata.Email,
usercoursedata.Category,
usercoursedata.SubCategory,
usercoursedata.fullname as CourseName,
usercoursedata.shortname as CourseShortName,
if (usercoursedata.gradetype is Null, "Full Course" ,usercoursedata.gradetype ) as
GradeType,
IF (soft_g_g.finalgrade is Null,"", soft_g_g.finalgrade) as FinalGrade,
IF (soft_g_g.timemodified is Null,
"" ,DATE_FORMAT(FROM_UNIXTIME(soft_g_g.timemodified), '%d-%b-%Y')) AS ModifiedDate
from
(Select * from
(Select sctype.*,
sue.userid
from soft_user_enrolments sue
INNER JOIN soft_enrol se
on se.id = sue.enrolid
INNER JOIN (
Select softCourse.*,gradItem.itemname as gradetype , gradItem.id as gradeitemid
from soft_grade_items gradItem
INNER JOIN
(Select sccc.id , IF(scc1.name IS NULL, sccc.subcategory, scc1.name) as Category ,
sccc.subcategory ,sccc.fullname,sccc.shortname from
(Select scc.name as subcategory ,sc.id, sc.fullname, sc.shortname, scc.parent from
soft_course sc
left outer join soft_course_categories scc on sc.category = scc.id) sccc
left outer join soft_course_categories scc1 on sccc.parent = scc1.id) softCourse
on softCourse.id = gradItem.courseid
) sctype
on sctype.id = se.courseid ) userCourseInfo
INNER JOIN (select id as userid1, Concat(firstname, " " , lastname) as Name, email
as Email,DATE_FORMAT(FROM_UNIXTIME(timecreated),

'%Y-%m-%d %H:%i:%s') AS 'Registerd Date' ,


department as Department, institution as Organization from soft_user)
usersInfo
On userCourseInfo.userid = usersInfo.userid1 ) usercoursedata
Left Outer Join soft_grade_grades soft_g_g
on usercoursedata.userid = soft_g_g.userid and usercoursedata.gradeitemid =
soft_g_g.itemid

**** Get Competencies for User (Template).

Select
templatedata.Email,
templatedata.LearningPlanTemplate,
templatedata.framework as CompetencyFramework,
templatedata.CompetencyName as Competency,
if(templatedata.framework like '%EXPRO Processes and Procedures%',
"Procedure" ,"OJT") as CompType,
Case
When sce.grade = 1 Then "Unaware"
When sce.grade = 2 Then "Aware"
When sce.grade = 3 Then "Practiced"
When sce.grade = 4 Then "Competent"
When sce.grade = 5 Then "Proficient"
When sce.grade = 6 Then "Expert"
ELSE 'Not Started' end as grades,
If (sce.notes is Null,"",sce.notes ) as Notes,
"Template" as TemplateBased,
IF (sce.timemodified is Null, "" ,DATE_FORMAT(FROM_UNIXTIME(sce.timemodified),
'%d-%m-%Y')) AS ModifiedDate,
IF (sce.timemodified is Null, "" ,DATE_FORMAT(FROM_UNIXTIME(templatedata.DueDate),
'%d-%m-%Y')) AS DueDate
from
(Select usercompetencyTemplate.*,
sccu.id as usercompetencyid,
sccu.status,
sccu.proficiency,
sccu.grade,
sccu.reviewerid
from
(
Select
userInfo.EmployeeName ,
userInfo.Email ,
userInfo.Department ,
userInfo.Organization ,
tmplateInfo.LearningPlanTemplate,
tmplateInfo.DueDate,
tmplateInfo.Framework ,
tmplateInfo.competencyName ,
userInfo.userid ,
tmplateInfo.competencyid,
tmplateInfo.templateid from
(
Select
id as userid,
Concat(firstname, " " , lastname) as EmployeeName,
email as Email,
DATE_FORMAT(FROM_UNIXTIME(timecreated), '%d-%m-%Y') AS
'Registerd Date' ,
department as Department,
institution as Organization
from soft_user
) userInfo
INNER Join
soft_competency_plan scp
INNER Join
(
Select sct.id as templateid,
Framework,
sct.shortname as LearningPlanTemplate ,
sct.duedate as DueDate,
sc.competencyid,
sc.shortname as competencyName
from soft_competency_template sct
INNER Join soft_competency_templatecomp sctc
INNER Join
(
Select compf.shortname as framework ,
comp.id as competencyid , comp.shortname ,
comp.description
from soft_competency comp
INNER JOIN soft_competency_framework compf
on comp.competencyframeworkid = compf.id
) sc
on sc.CompetencyID = sctc.competencyid and sct.id =
sctc.templateid
) tmplateInfo
on userInfo.userid = scp.userid and tmplateInfo.templateid =
scp.templateid
) usercompetencyTemplate
Inner Join soft_competency_usercomp sccu
on sccu.userid = usercompetencyTemplate.userid and sccu.competencyid =
usercompetencyTemplate.competencyid) templatedata
left OUTER JOIN
(
Select
id ,s.timemodified , s.usercompetencyid,s.grade ,s.note as notes
from soft_competency_evidence s
where id in (select max(id) from soft_competency_evidence group by
usercompetencyid)
) sce
on templatedata.usercompetencyid = sce.usercompetencyid

**** Get Competencies for User (Non Template).

Select
userInfos.Email,
compp.name as LearningPlanTemplate,
compt.framework as CompetencyFramework,
compt.shortname as Competency,
if(compt.framework like '%EXPRO Processes and Procedures%', "Procedure" ,"OJT") as
CompType,
Case
When sce.grade = 1 Then "Unaware"
When sce.grade = 2 Then "Aware"
When sce.grade = 3 Then "Practiced"
When sce.grade = 4 Then "Competent"
When sce.grade = 5 Then "Proficient"
When sce.grade = 6 Then "Expert"
ELSE 'Not Started' end as grades,
If (sce.notes is Null,"",sce.notes ) as Notes,
"Non Template" as TemplateBased,
IF (sce.timemodified is Null, "" ,DATE_FORMAT(FROM_UNIXTIME(sce.timemodified),
'%d-%m-%Y')) AS ModifiedDate,
IF (sce.timemodified is Null, "" ,DATE_FORMAT(FROM_UNIXTIME(compp.duedate), '%d-
%m-%Y')) AS DueDate
from soft_competency_plan compp
Inner join soft_competency_plancomp comppc
on comppc.planid = compp.id
Inner Join (
Select compf.shortname as framework ,
comp.id as competencyid , comp.shortname ,
comp.description
from soft_competency comp
INNER JOIN soft_competency_framework compf
on comp.competencyframeworkid = compf.id
) compt
On compt.competencyid = comppc.competencyid
Inner Join soft_competency_usercomp usercomp
on usercomp.competencyid = compt.competencyid and usercomp.userid = compp.userid
Inner Join
(
Select
id as userid,
Concat(firstname, " " , lastname) as EmployeeName,
email as Email,
DATE_FORMAT(FROM_UNIXTIME(timecreated), '%d-%b-%Y') AS 'Registerd Date' ,
department as Department,
institution as Organization
from soft_user

) userInfos
on userInfos.userid = compp.userid
left OUTER JOIN
(
Select
id ,s.timemodified , s.usercompetencyid,s.grade ,s.note as notes
from soft_competency_evidence s
where id in (select max(id) from soft_competency_evidence group by
usercompetencyid)
) sce
on usercomp.id = sce.usercompetencyid

You might also like