You are on page 1of 17

1.a. SELECT Avg(salary) as media FROM employees where department_id=80 b.

SELECT first_name, last_name FROM employees where salary>(select salary from employees where last_name='Grant') c. SELECT first_name, last_name FROM employees where department_id=(select department_id from departments where department_name='Sales') d. select a.first_name||' '||a.last_name as "Angajat",b.first_name||' '||b.last_name as "Manager" from employees a,employees b where a.manager_id=b.employee_id 2.a. Select last_name, first_name From employees Where manager_id IS NULL b. select first_name, salary from employees where manager_id=(select employee_id from employees where first_name='Kevin') c. select a.first_name, a.last_name, b.department_name from employees a, departments b where a.department_id=b.department_id AND a.commission_pct IS NOT NULL d. select a.first_name, a.last_name, b.department_name from employees a, departments b where a.department_id=b.department_id 3.a. select first_name, last_name, salary, hire_date

from employees where department_id=80 b. select first_name, last_name, salary from employees where department_id=(Select department_id from employees where first_name='Kevin') c. select j.job_title from jobs j, employees e where e.job_id=j.job_id And e.last_name='Whalen' AND e.first_name='Jennifer' d. select a.first_name, a.last_name, b.department_id from employees a, departments b WHERE a.department_id=b.department_id(+) 4.a. select cd_number as "Numar cd", title as "Titlu cd", producer as "Producator", year as "Anul fabricatiei" from d_cds Where MOD(length(title),2)=1 ORDER BY year DESC b. select title, producer from d_cds where year=(select max(year) from d_cds) c. select b.title, b.artist from D_TRACK_LISTINGS a, d_songs b where a.song_id=b.id AND a.track=1 d. select d.title as "Nume cd", s.title as "Nume melodie", s.artist from D_TRACK_LISTINGS t, d_cds d, d_songs s where d.year=2000 and t.cd_number=d.cd_number And s.id=t.song_id 5.a. select LOC_TYPE, ADDRESS, COMMENTS from D_venues

where id between 100 and 999 and address like '%o%' b. select * from D_venues where length(comments)=(select max(length(comments)) from d_venues) c. select count(*) from D_venues a, d_events b where a.loc_type<>'Private Home' AND a.id=b.venue_id d. select b.name, b.cost, a.address from D_venues a, d_events b where a.id=b.venue_id and a.loc_type='Private Home' 6.a. select first_name, last_name, email, phone from D_clients where email like '%yahoo%' b. select first_name, last_name from D_partners where partner_type='Manager' c. select name, event_date from D_events where client_number=(select client_number from d_clients where first_name='Lauren') d. select a.title, a.artist, b.description from D_songs a, d_types b where a.type_code=b.code and a.title like 'I%' 7.a. select avg(salary) as "salariu mediu" from f_staffs where staff_type<>'Manager' b.

select name, code from f_PROMOTIONAL_MENUS where end_date-start_date=(select min(end_date-start_date) from f_PROMOTIONAL_MENUS) c. select a.quantity from f_order_lines a, f_food_items b where a.food_item_number=b.food_item_number d. select a.first_name, a.last_name, b.order_number from f_orders b, f_customers a where a.id=b.cust_id(+) 8.a. SELECT phone_number, email FROM employees where commission_pct IS NOT NULL AND substr(first_name,1,1) IN( 'A','E','I', 'O', 'U') b. SELECT first_name, last_name FROM employees where hire_date=( Select max(hire_date) from employees) c. SELECT count(*), trunc(avg(salary+salary*(commission_pct/100)),3) FROM employees where department_id=(select department_id from departments where department_name='Sales') d. SELECT a.employee_id, a.first_name, a.last_name, b.end_date-b.start_date as "Numar zile" FROM job_history b, employees a where a.employee_id=b.employee_id 9.a. SELECT street_address as "Adresa", postal_code as "Cod postal", city as "Nume oras" FROM locations where country_id='US'and city like '%e' b. SELECT count(*)as "numar locatii"

FROM locations WHERE country_id<>(select country_id from locations where city='Seattle') c. SELECT country_id, country_name FROM countries WHERE region_id=(select region_id from regions where region_name='Europe') d. SELECT a.department_name, b.street_address FROM departments a, locations b WHERE a.location_id=b.location_id 10.a. select department_id,department_name from departments where upper(substr(department_name,1,1))=upper(substr(department_name,length(depart ment_name),length(department_name))) b. select first_name, last_name from employees where commission_pct=(select max(commission_pct) from employees) c. select department_name, department_id from departments where department_id not in( select department_id from employees where department_id is not null) 11. a. SELECT Lower('Atestat'), UPPER('Oracle'), 'subiect'||upper(substr('subiecte',8,8)) FROM dual b. SELECT * FROM f_staffs where ID=19 AND salary<50 AND birthdate BETWEEN to_date('30-01-1969','DD-MMYYYY') and to_date('31-12-1979','DD-MM-YYYY') c. SELECT salary, salary+salary*(3/100) as "Salariu marit" FROM f_staffs

where first_name='Bob' 12. a. SELECT 'Astzi, '|| to_char(SYSDATE, 'DD-MON-YYYY')|| ', plec la munte!!!' AS "Ce fac azi" FROM dual b. select a.first_name||' '||a.last_name||' --- '||a.hire_date as "Angajat",b.first_name||' '|| b.last_name||' --- '||b.hire_date as "Manager" from employees a,employees b where a.manager_id=b.employee_id and a.hire_date<b.hire_date c. select department_id, round(avg(salary),3) from employees Group by department_id 13. a. select substr('informatica',2,3) from dual b. select title, duration, artist from d_songs where title like '%r' c. SELECT a.title, a.artist, b.comments FROM d_play_list_items b, d_songs a WHERE b.song_id=a.id ORDER BY a.artist

14.a. SELECT REPLACE('A venit primavara pe la noi',' ', '*') FROM dual b. SELECT first_name,last_name FROM d_clients WHERE client_number in(select client_number from d_events where substr(to_char(event_date,'DD-MM-YYYY'),4,2)='04')

SAU SELECT * FROM d_events a, d_clients b where substr(to_char(a.event_date),4,2)=04 AND a.client_number=b.client_number

c. SELECT first_name, last_name, phone FROM d_clients WHERE email like '%yahoo.com%' 15.a. SELECT Replace('Iarna e frumoasa', 'a','') From dual b. SELECT * From f_promotional_menus Order by start_date desc c. INSERT INTO f_customers VALUES ('888', 'Eve', 'Evelina', 'Unirii', 'Targu-Jiu', 'RO', '382990', '988882223') 16.a. select first_name, last_name from employees where MOD(salary,3)=0 b. select first_name, last_name, trunc(salary+salary*(4.2/100),2) as "Salariu marit" from employees where department_id=80 c. select b.first_name, b.last_name, b.salary from departments a, employees b where b.department_id=a.department_id AND a.location_id='1700' 17. a. SELECT department_id FROM employees GROUP BY department_id HAVING avg(salary)>(select avg(salary) from employees where department_id=60)

b. INSERT INTO employees VALUES('90','Alin','Popescu','oracle','0744123456','30-012008','AD_VP','12000',null,'101','90') c. SELECT a.first_name, a.last_name, a.department_id, b.department_name FROM employees a full outer join departments b ON(a.department_id=b.department_id) 18.a. SELECT b.job_title, a.start_date FROM job_history a, jobs b WHERE a.job_id=b.job_id AND b.min_salary BETWEEN 2000 AND 10000 b. SELECT count(*) FROM jobs WHERE (min_salary between 3000 and 20000) AND (max_salary between 3000 and 20000) c. SELECT department_id, MAX(end_date-start_date) FROM job_history GROUP BY department_id 19. a. SELECT title, artist From d_songs where artist like '%o%' b. SELECT title From d_songs where type_code=12 OR type_code=77 order by title c. SELECT b.title, b.artist, a.description, b.duration From d_types a, d_songs b where a.code=b.type_code 20.a.

SELECT first_name, last_name, salary+salary*(25/100) as "Salariu indexat" From employees where department_id IN(50, 90, 110) AND hire_date>'07-06-1994' b. SELECT first_name, last_name, salary+salary*(33/100) as "Salariu indexat" From employees where department_id=50 AND first_name LIKE '%e%' c. SELECT * From employees where salary=(select MAX(salary) from employees)

21.a. SELECT 'Mai sunt aproximativ ' ||trunc((to_date('25 12 2012','DD MM YYYY')SYSDATE)/30,0)||' luni pana la Craciun.' as "Numar de luni" From dual b. create table copy_employees as select * from employees select first_name, last_name, salary, department_id from copy_employees Where salary BETWEEN 10000 AND 20000 c. select first_name, salary+salary*(10/100) from copy_employees order by first_name DESC d. alter table copy_employees add adresa varchar2(50) alter table copy_employees drop column hire_date alter table copy_employees drop column commission_pct select * from copy_employees order by last_name 22.a. Select ADD_MONTHS(sysdate, 10) from dual b. create table copy_d_cds as select * from d_cds

select title, producer from copy_d_cds where year>2000 c. ???????? d. INSERT INTO copy_d_cds VALUES('99','Morandi N3xt','Universal Music','2006') SELECT * FROM copy_d_cds order by title 23.a. select 'Prima zi a lunii urmatoare este: '||(last_day(sysdate)+1) from dual b. - create table copy3_employees ( first_name, last_name, hire_date ) as select first_name, last_name, hire_date from employees select * from copy3_employees Order by last_name c. select * from copy3_employees where first_name LIKE '%a%' d. select MAX(salary), MIN(salary), avg(salary) from employees 24. a.

SELECT 'n acest an luna februarie are '||substr(last_day(to_date('February 01, 2012', 'Month dd, YYYY')),1,2)||' de zile' From dual b. create table copy_d_songs as select * from d_songs SELECT * FROM copy_d_songs order by artist c. SELECT * FROM copy_d_songs WHERE substr(duration,1,2)>5 d. INSERT INTO copy_d_songs VALUES('51','Right Here Waiting','6 min',' Richard Marx ','60') UPDATE copy_d_songs SET type_code=type_code+1 SELECT * FROM copy_d_songs

25. a. SELECT 'Astazi este a '||to_char(sysdate,'DDD')||'-a zi din an' from dual b. - create table copy_d_events as select * from d_events - select * from copy_d_events order by event_date c. INSERT INTO copy_d_events VALUES('1','Nume1','01 JAN 2012','Descriere1 ','30','30','30','30','30 ') INSERT INTO copy_d_events VALUES('2','Nume2','02 JAN 2012','Descriere2 ','40','40','40','40','40 ') select name,description,cost+cost*(19/100) from copy_d_events

d. alter table copy_d_events drop column package_code alter table copy_d_events drop column theme_code select * from copy_d_events 26. select upper('Examen de atestat la informatica') from dual 27. select 'Textul Examen de atestat la informatic are '||length('Examen de atestat la informatic')||' caractere' from dual 28. select REPLACE('E bine bine e foarte bine','bine','rau') from dual 29. select REPLACE(LOWER('Dou rae fac dou ou n dou zile'),'dou','') from dual 30. select rpad('Examen',15,'+')||' si '||lpad('Informatica',20,'-') from dual 31.a. SELECT 'Astazi este '||to_char(sysdate,'DD MONTH YYYY') from dual b. SELECT last_name, department_id from employees where department_id=20 OR department_id=50 order by last_name c. SELECT first_name, last_name from employees where job_id=(select job_id from jobs where job_title='Programmer') d. SELECT a.first_name, a.last_name FROM employees a full outer join departments b

ON(a.department_id=b.department_id) 32.a. SELECT NEXT_DAY(SYSDATE,'FRIDAY') FROM DUAL b. SELECT first_name, last_name, salary*12 as "Yearly salary" FROM employees ORDER BY first_name c. SELECt e.last_name,e.first_name, d.department_name FROM departments d, employees e Where e.employee_id=d.manager_id

d. SELECT a.department_id FROM departments a FULL OUTER JOIN employees b ON(a.department_id=b.department_id 33.a. SELECt REPLACE('mississippi', 'i', '&') FROM dual b. SELECt last_name, first_name, salary*(10/100) as "salariu indexat" FROM employees Where last_name like '%s' order by salary desc c. SELECt title FROM d_cds where year=(select MAX(year) from d_cds) OR year=(select MIN(year) from d_cds) d. SELECT a.job_id, c.job_title FROM job_history a, employees b, jobs c WHERE b.hire_date<a.start_date AND a.employee_id=b.employee_id AND a.job_id=c.job_id 34.a.

SELECT Next_day(add_months(sysdate,6), 'FRIDAY') FROM dual

b. SELECT * FROM Employees Where salary>(select avg(salary) from employees) c. SELECT title FROM d_songs WHERE substr(duration,1,2)<=5 d. SELECT a.grade_level, b.last_name, b.salary FROM job_grades a, employees b where salary BETWEEN a.lowest_sal AND a.highest_sal 35.a. SELECT REPLACE('It is a small world','It is a small world','WONDERFUL WORLD') FROM dual b. SELECT title, producer FROM d_cds WHERE title like '%a%' c. SELECT * FROM employees where commission_pct IS NULL d. SELECT a.name, a.cost, b.code FROM d_events a, d_packages b WHERE a.package_code=b.code AND a.cost BETWEEN b.low_range AND b.high_range 36. a. SELECT REPLACE('caracatita','ca','ta') FROM dual b.

SELECT a.employee_id, b.first_name, b.last_name, round(MONTHS_BETWEEN(a.end_date,a.start_date),0) AS "Numarul de luni lucrate" FROM job_history a, employees b WHERE a.employee_id=b.employee_id c. SELECT round(avg(a.salary),2), b.department_id From f_staffs a, departments b group by b.department_id d. SELECT a.event_id, a.song_id, b.cd_number From D_PLAY_LIST_ITEMS a, d_track_listings b where a.song_id=b.song_id 37.a. SELECT length('caracatita')-instr('atitacarac','c')+1 From dual b. SELECT first_name, last_name, salary,salary+salary*(commission_pct/100) From employees c. SELECT * From f_staffs where birthdate>(select birthdate from f_staffs where last_name='Tuttle')

d. SELECT a.first_name, a.last_name, b.department_name From employees a, departments b WHERE a.department_id=b.department_id 38.a. SELECT next_day(to_date('01-01-2008','DD-MM-YYYY'),'FRIDAY') as "Prima zi de vineri din 2008" From dual b. SELECT first_name, last_name, substr(to_char(hire_date),4,3) as "Luna angajarii" From employees c.

SELECT * FROM employees where department_id=(select department_id from employees where last_name='Grant') d. Select a.last_name as "Numele angajatului", d.last_name as "Numele managerului" FROM employees a, employees d where d.employee_id=a.manager_id 39.a. SELECT 'ziua '||substr(to_char(SYSDATE,'dd mm YYYY'),1,2)||', '||'luna '|| substr(to_char(SYSDATE,'dd mm YYYY'),3,4)||', '||'anul '||substr(to_char(SYSDATE,'dd mm YYYY'),6,8) From dual b. UPDATE d_partners SET specialty=0 WHERE specialty is NULL c. SELECT first_name, last_name from employees where department_id=(select department_id from departments where department_name='Marketing') d. SELECT a.first_name, a.last_name, b.department_name, b.department_id from employees a FULL OUTER JOIN departments b ON(a.department_id=b.department_id) 40.a. SELECT to_date(SUBSTR('may 15, 2008',2,10),'MON dd, YYYY') from dual b. UPDATE d_clients SET PHONE=SUBSTR(phone,4,10) SELECT * FROM d_clients c.

SELECT * FROM employees where salary>(select avg(salary) from employees) d. SELECT a.first_name, a.last_name, b.department_name, b.department_id from employees a FULL OUTER JOIN departments b ON(a.department_id=b.department_id)

Related Interests