إنتقال للمحتوى

  • تسجيل الدخول عبر الفيس بوك تسجيل الدخول عبر تويتر Log In with LinkedIn Log In with Google      تسجيل دخول    
  • إنشاء حساب

صورة
- - - - -

مثال محبوك عن Decode


لا توجد ردود على هذا الموضوع

#1 fateh_cis

fateh_cis

    عضو

  • الأعضــاء
  • 8 مشاركة

تاريخ المشاركة 22 July 2009 - 12:40 PM

CREATE a matrix query to display the job ,the salary for that job based on department number, and the total salary for that job ,for departments 10 , 50 ,80 , 90


SELECT JOB_ID , 
sum (case department_id when 20 then (salary) end) "20" ,
sum (case department_id when 50 then(salary) end ) "50",
sum (case department_id when 80 then (salary) end) "80",
sum (case department_id when 90 then (salary) end ) "90" ,
sum (salary) total
FROM employees GROUP BY job_id



SELECT job_id , 
Sum (decode ( department_id , 20 , salary) )"20",
Sum (decode ( department_id , 90 , salary) )"90",
Sum (decode ( department_id , 80 , salary) )"80",
Sum (decode ( department_id , 50 , salary) )"50",
Sum (salary) “Total”
FROM employees GROUP BY job_id