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/ 2
List the department table:
• select * from dept;
Another way(slide 20); • select deptcode,deptname,budget from dept; List all department code with the names of their departments(slide 22 changed) •select deptcode,deptname from dept; list all department names(slide 25 changed): •select deptname from dept; list all department names using distinct(slide26 changed): •select distinct deptname from dept; List all employees of the accounts department(slide 27) •select empname,deptcode from emp where deptcode='ACCT'; List all officers(slide 28): •select empname,gradecode from emp where gradecode='GC6'; List the employees with their department name(slide 30): •select empname,deptname from emp,dept where emp.deptcode=dept.deptcode; list the employees with their department code and department name(slide 31): •select empname,deptname,dept.deptcode from emp,dept where emp.deptcode=dept.deptcode; list all young employees(slide 33 changed) •select empname,birthdate from emp where birthdate > '1980-01-01'; List employees of admin departments(slide 35): •select empname,deptcode from emp where deptcode in ('ACCT','PRCH','PERS'); List employees of non-admin departments(slide 37): •select empname,deptcode from emp where deptcode not in ('ACCT','PRCH','PERS'); List staff between certain age(slide 38): •select empname,birthdate from emp where birthdate between '1982-12-31' and '1992- 12-31'; List all employees with UMA in their names(slide 39): •select empname from emp where upper(empname) like '%UMA%'; List the employees who have not been assigned to any supervisor(slide 40): •select empname,supcode from emp where supcode is null; list the female employees who have just completed 5 years(slide 41): •select empname,sex,joindate from emp where sex='F' and joindate between(current_date-5*365) and (current_date-6*365); List female employees who are either 50 years or more or have more than 20 years experience(slide 42): •select empname from emp where birthdate<(current_date-50*365) or joindate<(current_date-20*365) and sex='F'; list salesmen who are either 50 years or more or have more than 20 years experience(slide 43) •select empname from emp where desigcode='SLMN' and (birthdate<(current_date- 50*365) or joindate<(current_date-20*365)); List 1% of take-home pay of all employees(slide 44): • select empcode,(basic + allow-deduct)* 0.01 from salary where salmonth='2012-01- 02'; List the present age of all employees(slide 46 changed): •select empname,timestampdiff(year,birthdate,curdate()) as age from emp; List the employees with the highest salary(slide 49) •select empname,basicpay from emp where basicpay >= all(select basicpay from emp); List all the employees not having the highest salary(slide 53): •select empname from emp where basicpay < any(select basicpay from emp); List the employees working for 'accounts' or 'purchase' departments(slide 54): •select empname from emp where deptcode='ACCT' union select empname from emp where deptcode='PRCH'; List the employees working for 'accounts' and 'purchase' departments(slide 56 changed): •select deptcode,empname from emp where deptcode in('ACCT','PRCH'); List the employees working for 'accounts' but not for 'purchase' department(slide 57 changed): •select deptcode,empname from emp where deptcode='ACCT' and not 'PRCH'; LIst all employees ordered by age(slide 62 changed): •select empname,timestampdiff(year,birthdate,curdate()) as age from emp order by birthdate; List middle level staff according to seniority(slide 64 List all according to age and seniority(slide 66 changed): •select empname, timestampdiff(year,birthdate,curdate()) as age, gradecode,gradelevel from emp order by gradecode desc,gradelevel desc; Count employees reporting to singh(slide 68): •select count(*) from emp where supcode='7839'; Count employees reporting to singh(slide 69): •select count(*) from emp where supcode='empcode of singh'; Count employees reporting to singh(slide 70): •select count(*) from emp where supcode=(select empcode from emp where empname='singh'); List the number of staff reporting to each supervisor(slide 71): •select supcode,count(*) from emp group by supcode order by supcode; List the total take-home pay during 96-97 for all employees(slide 73); •select empcode, sum(basic+allow-deduct) as pay from salary where salmonth between '2011-01-12' and '2012-01-12' group by empcode order by empcode; List the maximum and minimum salaries in grades(slide 75): •select gradecode,max(basic),min(basic) from grade group by gradecode order by gradecode; List the number of staff reporting to each supervisor having more than 3 people working under them(slide 78): •select supcode,count(*) from emp group by supcode having count(*)>3 order by supcode;