SQL set2 qns1

download SQL set2 qns1

If you can't read please download the document

description

SQL

Transcript of SQL set2 qns1

1. Which statement about joining tables with a non-equijoin is true?

a. A WHERE clause must specify a column in one table that directly corresponds to a column in the second table

b. The tables being joined must NOT have any columns with the same name

c. The number of join conditions required is always one less than the number of tables being joined

d. No more than three tables can be joined using a non-equijoin

e. The columns being joined must have compatible data types

2. Consider the following SELECT statement:

SELECTename, emp_number, salary
FROM employee
WHEREdept_number = (SELECT dept_number
FROM department
WHERElocation IN('CHICAGO', 'NEW YORK'))

Why does this statement return an error?

a. A multiple-row subquery returns one row

b. A single-row subquery returns more than one row

c. A multiple-column subquery returns one column

d. A multiple-row query uses a single-row subquery

3. Considerthe following SELECT statement:

SELECT ename, empno, sal
FROM emp
WHEREdeptno = (SELECTdeptno
FROM dept
WHEREUPPER(loc) = UPPER('&loc'))

When executing this statement, what could be the result?

a. The statement executes successfully if the LOC column in the DEPT table has unique values

b. The statement fails if the values returned from a multiple-row subquery are compared with an equality operator in the main query

c. The statement fails because an ampersand (&) character cannot be used in the subquery of a SELECT statement

d. The statement executes successfully, but does not return the expected results because of the use of the UPPER function twice in the subquery

4. Examine the following statement:

SELECT empno_seq.CURRVAL
FROM SYS.dual;

Which value is displayed?

a. Current value of the EMPNO_SEQ sequence

b. Current value of the EMPNO_SEQ cursor

c. Values of the EMPNO_SEQ column

d. Current value of the EMPNO_SEQ index

5. If a database is queried with the following command:

SELECT object_name
FROM all_objects
WHERE object_type = 'TABLE';

Which values are displayed?

a. Only the names of all the tables that can be accessed

b. Only the names of all the objects that can be accessed

c. Only the names of the objects that are owned

d. Only the names of the tables that are owned

6. The ITEM table contains the following columns:

IDNUMBER(7)PK
SALE_PRICENUMBER(7,2)

Evaluate the following SQL statements:

1.SELECT MAX(sale_price), MIN(sale_price), AVG(sale_price)
FROM ITEM;
2.SELECT ROUND(MAX(sale_price),2), ROUND(MIN(sale_price),2), ROUND(AVG(sale_price),2)
FROM ITEM
GROUP BY sale_price;

How will the results differ?

a. Statement 2 will only display one row of results; statement 1 could display more than one

b. One of the statements will generate an error

c. Statement 1 will display three values; statement 2 will display three values for each sale price

d. Statement 1 will display a result for each sale price; statement 2 will display a result for each item

7. Consider the following SELECT statement:

SELECTdept_no "Departments", MAX(salary) "Max Salaries"
FROM employee
WHEREdept_no IN(200, 300, 400)
GROUP BY Departments
HAVINGMAX(salary) > 60000;

Due to which clause does this statement fail?

a. Group By

b. Where

c. Select

d. Having

8. Which of the following commands cause a transaction to end?

a. DELETE

b. ALTER

c. INSERT

d. UPDATE

e. ROLLBACK

9. Which statements about data types are true?

a. The BLOB data type stores character data up to four gigabytes

b. The TIMESTAMP data type is an extension of the VARCHAR2 data type

c. The CHAR data type should be used for fixed-length character data

d. The INTERVAL YEAR TO MONTH data type allows time to be stored as an interval of years and months

10. Which of the following statements regarding the use of subqueries are true?

a. A subquery used with the IN operator must return multiple rows

b. A subquery can be used in a CREATE VIEW statement, regardless of the number of rows it returns

c. A subquery can be used in the SET clause of an UPDATE statement, regardless of the number of rows it returns

d. A subquery used in an INTO clause of a SELECT statement must return only one column, but can return multiple rows

e. A subquery CANNOT be used in the GROUP BY clause of a SELECT statement

11. Evaluate the following SQL*Plus command:

START empdetail

Which task will this command accomplish?

a. It runs the EMPDETAIL.SQL script file

b. It creates the EMPDETAIL.SQL file using the default file extension

c. It executes the EMPDETAIL.SQL PL/SQL routine

d. It invokes the editor to edit the contents of the EMPDETAIL file

12. Evaluate the following SELECT statement:

SELECT emp_id, name
FROMemp
WHERE emp_id NOT IN (SELECTemp_id
FROM emp
WHEREdept_id = 30
ANDjob = 'SALESMAN');

What would happen if the inner query returned a NULL value?

a. No rows would be selected from the EMPLOYEE table

b. A syntax error would be returned

c. All the EMPLOYEE_ID and NAME values in the EMPLOYEE table would be displayed

d. Only the rows with EMPLOYEE_ID values equal to NULL would be included in the results

13. In which clauses of a SELECT statement can substitution variables be used?

a. The SELECT and FROM clauses, but NOT the WHERE clause

b. The SELECT, FROM, WHERE, and GROUP BY clauses, but NOT the ORDER BY clause

c. The SELECT, WHERE, GROUP BY, and ORDER BY clauses, but NOT the FROM clause

d. The SELECT and FROM clauses, but NOT the WHERE clause

e. The SELECT, FROM, WHERE, GROUP BY, ORDER BY, and HAVING clauses

14. Which operators can be used in an outer join condition?

a. AND

b. IN

c. OR

d. =

15. What is the correct use of the Trunc command on a date?

a. TRUNC=To_Date('09-Jan-02,DD-MON-YY,'YEAR',"Date" from Dual;

b. Select TRUNC(To_Date('09-Jan-02,DD-MON-YY,YEAR')) "DATE" from Dual;

c. Date =TRUNC(To_DATE('09-Jan-02','DD-MON-YY'),'YEAR'),'YEAR)"DATE: from DUAL;

d. SELECT TRUNC(TO_DATE('12-Feb-99','DD-MON-YY'), 'YEAR') "Date " FROM DUAL;

16. Which type of join should be written to performan outer join of tables A and B that returns all rows from B?

a. Any outer join

b. A left outer join

c. A cross join

d. A right outer join

e. An inner join

17. How many join conditions should be there to avoid a Cartesian Join for joining three tables?

a. 1

b. 2

c. 3

d. None of the above

18. Which Data Dictionary view holds information about the column in a view?

a. USER_VIEWS

b. USER_VIEW_COLUMNS

c. USER_TAB_COLUMNS

d. USER_ALL_COLUMNS

19. Which of the following views should a user query to display the columns associated with the Constraints on a table owned by the user?

a. USER_CONSTRAINTS

b. USER_OBJECTS

c. ALL_CONSTRAINTS

d. USER_CONS_COLUMNS

e. USER_COLUMNS

20. Which of the following SELECT statements will get the result 'ELCOME' from the string 'WELCOME'?

a. SELECT SUBSTR ('WELCOME',1) FROM dual;

b. SELECT INITCAP(TRIM('WELCOME', 1,1) FROM dual;

c. SELECT LOWER (SUBSTR ('WELCOME', 2,1) FROM dual;

d. SELECT LOWER (SUBSTR('WELCOME', 2,1) FROM dual;

e. SELECT LOWER (TRIM ('W' FROM 'WELCOME')) FROM dual;

21. Which script displays '01-MAR-03' when the JOIN_DATE value is '01-MAR-02'?

a. SELECT ROUND(join_date, 'YEAR')
FROMEmp;

b. SELECT ROUND(join_date, 'DAY')
FROMEmp;

c. SELECT ROUND(join_date, 'MONTH')
FROMEmp;

d. SELECT ROUND(TO_CHAR(join_date, 'YYYY'))
FROMEmp;

22. Evaluate the following statement:
TRUNCATE TABLE product;
Which of the following users can successfully issue this statement?

a. The owner of the INVENTORY table

b. Any user with access to the PUBLIC schema

c. Any user with the DELETE ANY TABLE system privilege

d. Any member of the CONNECT and RESOURCE roles

23. What does SQL stand for?

a. Strong Question Language

b. Structured Question Language

c. Structured Query Language

d. Start up Language

1. Which SQL SELECT statement performs a projection, a selection, and join when executed?

a. SELECT id_number,seller_id
FROM ITEM
ORDER BY seller_id, id_number;

b. SELECT id_number,seller_id
FROM ITEM
WHERE seller_id = 'F10032';

c. SELECT seller_id, city
FROM SALLER
AND seller_id = 'F10032'
ORDER BY city;

d. SELECT p.id_number, s.seller_id, seller.city
FROM ITEM p, SALLER s
WHERE p.seller_id = m.seller_id
AND m.seller_id='F10032';

2. Which component is a literal in the following select statement?

Select 'Emp name :'||ename from emp where deptno=20;

a. ename.

b. 20.

c. emp name.

d. ||.

5Which of the following SQL statement returns a numeric value?

a. SELECT ADD_MONTHS(MAX (hire_date), 6) FROM EMP;

b. SELECT ROUND(hire_date)FROM EMP;

c. SELECT sysdate-hire_date FROM EMP;

d. SELECT TO_NUMBER(hire_date + 7)FROM EMP;

6. _______ operator can be used with a multiple row SubQuery.

a. =

b. LIKE

c. BETWEEN

d. NOT IN

e. Is

7. The names of the employees who have been with the company for more than five years is to be listed. Which of the following SQL statements will display the required results?

a. SELECT ENAME FROM EMP WHERE SYSDATE-HIRE_DATE>5

b. SELECT ENAME FROM EMP WHERE HIRE_DATE-SYSDATE > 5

c. SELECT ENAME FROM EMP WHERE (SYSDATE-HIRE_DATE)/365 > 5

d. SELECT ENAME FROM EMP WHERE (SYSDATE-HIRE_DATE)* 365 > 5

8. Examine the structures of the EMPLOYEE and DEPARTMENT tables:

EMPLOYEE
------------------
EMP_IDNUMBERNOT NULL PK
NAMEVARCHAR(30) NOT NULL
FNAME VARCHAR(25) NOT NULL
DEPT_NO NUMBER
TITLE VARCHAR2(25)

DEPARTMENT
------------------------
DEPT_IDNUMBERNOT NULL PK
DEPT_NAMEVARCHAR2(25)

A list of departments has to be created including the department name that have more than three administrative assistants. Which SELECT statement will produce the desired result?

a. SELECT d.dept_name
FROM employee e JOIN department d
ON (e.dept_no = d.dept_id)
WHERE LOWER(title) = 'administrative assistant'
GROUP BY dept_name
HAVING COUNT(emp_id) > 3;

b. SELECT dept_name
FROM employee e JOIN department d
ON (e.dept_no = d.dept_id)
WHERE LOWER(title) = 'administrative assistant'
AND COUNT(*) > 3;

c. SELECT dept_name
FROM employee NATURAL JOIN department
WHERE LOWER(title) = 'administrative assistant'
GROUP BY dept_name
HAVING COUNT(emp_id) > 3;

d. SELECT dept_name
FROM employee
GROUP BY dept_no
HAVING LOWER(title) = 'administrative assistant' AND COUNT(*) > 3;

9. The PRODUCT table contains the following columns:

PRODUCT_ID NUMBER(9)
DESCRIPTIONVARCHAR2(20)
COST NUMBER(5,2)
MANUFACTURER_IDVARCHAR2(10)

The product costs needs to be displayed with the following results:
1. The cost displayed for each product is increased by 20 percent.
2. The product manufacturer id must be 5001, 5020, or 5050.
3. Twenty percent of the original cost is less than $4.

Which statement should be used?

a. SELECTdescription, cost * 1.20
FROM product
WHEREcost * .20 < 4
AND manufacturer_id = ('5001','5020','5050');

b. SELECTdescription, cost * .20
FROM product
WHERE cost * .20 < 4.00
ANDmanufacturer_id BETWEEN '5001' AND '5050';

c. SELECTdescription, cost * 1.20
FROM product
WHERE cost * .20 < 4.00
AND manufacturer_id IN ('5001', '5020', '5050');

d. SELECTdescription, cost * 1.20
FROM product
WHERE cost * .20 < 4.00
AND manufacturer_id ANY('5001', '5020', '5050');

10. Consider the following SELECT statement:

SELECT emp_id, name
FROMemployee
WHERE emp_id NOT IN (SELECTemp_id
FROM employee
WHEREdepart_id = 30
AND job = 'CLERK');

What would happen if the inner query returned a NULL value?

a. No rows would be selected from the EMPLOYEE table

b. A syntax error would be returned

c. All the EMP_ID and NAME values in the EMPLOYEE table would be displayed

d. Only the rows with EMP_ID values equal to NULL would be included in the results

11. In a SELECT statement that includes a WHERE clause, where is the GROUP BY clause placed statement?

a. Immediately after the SELECT clause

b. Before the WHERE clause

c. After the ORDER BY clause

d. After the WHERE clause

12. A database was queried with the following command:

SELECT name, salary, dept_id FROM employee WHERE salary >
(SELECT AVG(salary) FROM employee WHERE dept_no =
(SELECT dept_no FROM employee WHERE last_name =
(SELECT last_name FROM employee WHERE salary > 50000)));

Which SELECT clause is evaluated first?

a. SELECT dept_no

b. SELECT last_name

c. SELECT name, salary, dept_id

d. SELECT AVG(salary)

13. find the name of the employee from emp table whose fname second charcter begins with 'e'

a. select * from emp where fname like'_e%'

b. select * from emp where fname like'e%'

c. select * from emp where fname like'_e'

d. select * from emp where fname like'ae%'

1. Which Data Dictionary view holds information about the column in a view?

a. USER_VIEWS

b. USER_VIEW_COLUMNS

c. USER_TAB_COLUMNS

d. USER_ALL_COLUMNS

2. Which of the following SQL statements should be used to remove a view called EMP_DEPT_VU from the schema?

a. DROP emp_dept_vu;

b. DELETE emp_dept_vu;

c. REMOVE emp_dept_vu;

d. DROP VIEW emp_dept_vu;

e. DELETE VIEW emp_dept_vu;

f. REMOVE VIEW emp_dept_vu;

3. The STUDENTS table needs to be modified to add a primary key on the STUDENT_ID column. The table is currently empty. Which of the following statements will accomplish the task?

a. ALTER TABLE students ADD PRIMARY KEY student_id;

b. ALTER TABLE students ADD CONSTRAINT PRIMARY KEY (student_id);

c. ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY student_id;

d. ALTER TABLE students ADD CONSTRAINT stud_id_pk PRIMARY KEY (student_id);

e. ALTER TABLE students MODIFY CONSTRAINT stud_id_pk PRIMARY KEY (student_id);

4. Examine the structure of the EMPLOYEES and NEW_EMPLOYEES tables given below:

EMPLOYEES
---------------------
EMPLOYEE_ID NUMBER Primary Key
FIRST_NAME VARCHAR2 (20)
LAST_NAME VARCHAR2 (20)
HIRE_DATE DATE

NEW_EMPLOYEES
------------------------
EMPLOYEE_ID NUMBER Primary Key
NAME VARCHAR2 (40)

Which of the following DELETE statements is valid?

a. DELETE FROM employees WHERE employee_id = (SELECT employee_id FROM employees);

b. DELETE * FROM employees WHERE employee_id = (SELECT employee_id FROM new_employees);

c. DELETE FROM employees WHERE employee_id IN (SELECT employee_id FROM new_employees WHERE name ='Carrey');

d. DELETE * FROM employees WHERE employee_id IN (SELECT employee_id FROM new_employees WHERE last_name ='Carrey'

5. Which of the following CREATE TABLE statements will fail?

a. CREATE TABLE time1 (time1 NUMBER(9));

b. CREATE TABLE time (time_id NUMBER(9));

c. CREATE TABLE date (time_id NUMBER(9));

d. CREATE TABLE time* (time_id NUMBER(9));

e. CREATE TABLE $time (time_id NUMBER(9));

f. CREATE TABLE datetime (time_id NUMBER(9));

6. What is the syntax for removing a PRIMARY KEY constraint and all its dependent constraints?

a. ALTER TABLE table_name
REMOVE CONSTRAINT PRIMARY KEY CASCADE;

b. ALTER TABLE table_name
DROP PRIMARY KEY CASCADE;

c. ALTER TABLE table_name
DISABLE CONSTRAINT PRIMARY KEY CASCADE;

d. A PRIMARY KEY constraint CANNOT be removed if it has dependent constraints

7. Which statement type would be used to remove transactions more than one year old from the TRX table?

a. DCL

b. DML

c. DDL

d. TCL

e. DRL

8. The PRIMARY KEY constraint was disabled on the ID column in the Product table and all the values in the Product table were updated. The constraint is to be enabled and it should be verified that the new ID column values do not violate the constraint. If any of the ID column values do not conform to the constraint, an error message should be returned.
Evaluate the following statement:

ALTER TABLE product
ENABLE CONSTRAINT product_id_pk;

Which statement is true?

a. The statement will execute, but will NOT enable the PRIMARY KEY constraint

b. The statement will achieve the desired results

c. The statement will execute, but will NOT verify that values in the ID column do NOT violate the constraint

d. The statement will return a syntax error

9. A user JOE needs to be created and this user should be allowed to create and drop tables in any schema.He should be able to create procedures and sequences only in his schema. Which script should be used to achieve these results?

a. CREATE USER joe
IDENTIFIED BY joe123;
GRANT DROP ANY TABLE, CREATE SEQUENCE, CREATE PROCEDURE
TO joe

b. CREATE USER joe
IDENTIFIED BY joe123;
GRANT CREATE TABLE, DROP TABLE, CREATE SEQUENCE, CREATE PROCEDURE
TO joe

c. CREATE USER joe
IDENTIFIED BY joe123;
GRANT CREATE SESSION, CREATE ANY TABLE, DROP ANY TABLE, CREATE SEQUENCE, CREATE PROCEDURE
TO joe

d. CREATE USER joe
IDENTIFIED BY joe123;
GRANT CREATE SESSION, DROP ANY TABLE, CREATE SEQUENCE, CREATE PROCEDURE
TO joe

10. Which statement about a sequence is true?

a. A sequence can only be used to create a primary key value

b. One sequence can be used for multiple tables in the same schema

c. Creating a sequence causes sequence numbers are stored in a table

d. A sequence slows down the efficiency of accessing sequence values cached in memory

11. The MANAGER role should be given the ability to select from insert into and modify existing rows in the STUDENT_GRADES table.
Anyone given this MANAGER role should be able to pass those privileges on to others. Which statement accomplishes this?

a. GRANT select, insert, update ON student_grades TO manager;

b. GRANT select, insert, update ON student_grades TO ROLE manager

c. GRANT select, insert, modify ON student_grades TO manager WITH GRANT OPTION;

d. GRANT select, insert, update ON student_grades TO manager WITH GRANT OPTION

12. A view was created with the following command:

CREATE FORCE VIEW first_vu
AS SELECT first_name ||' '|| last_name "Employee Names"
FROM employee
ORDER BY last_name, first_name;

Which clause causes an error?

a. CREATE FORCE VIEW first_vu

b. ORDER BY last_name, first_name

c. FROM employee

d. AS SELECT first_name ||' '|| last_name "Employee Names"

1. What is the correct use of the Trunc command on a date?

a. TRUNC=To_Date('09-Jan-02,DD-MON-YY,'YEAR',"Date" from Dual;

b. Select TRUNC(To_Date('09-Jan-02,DD-MON-YY,YEAR')) "DATE" from Dual;

c. Date =TRUNC(To_DATE('09-Jan-02','DD-MON-YY'),'YEAR'),'YEAR)"DATE: from DUAL;

d. SELECT TRUNC(TO_DATE('12-Feb-99','DD-MON-YY'), 'YEAR') "Date " FROM DUAL;

2. Which type of join should be written to perform an outer join of tables A and B that returns all rows from B?

a. Any outer join

b. A left outer join

c. A cross join

d. A right outer join

e. An inner join

3. How many join conditions should be there to avoid a Cartesian Join for joining three tables?

a. 1

b. 2

c. 3

d. None of the above

4. Top N analysis requires ____________ and ____________.

a. The use of rowed& Only an inline view

b. a GROUP BY clause & Only an inline view

c. an ORDER BY clause & An inline view and an outer query

d. None of the above

5. Examine the code given below:

SELECT employee_id FROM employees WHERE commission_pct=.5 OR salary > 23000

Which of the following statement is correct with regard to this code?

a. It returns employees who have 50% of the salary greater than $23,000:

b. It returns employees who have 50% commission rate or salary greater than $23,000:

c. It returns employees who have 50% of salary less than $23,000:

d. None of the above

6. The STUDENT_GRADES table has the following columns:
STUDENT_IDNUMBER (12)

SEMESTER_ENDDATE

GPANUMBER (4, 3)

Which of the following statements finds the highest Grade Point Average (GPA) per semester?

a. SELECT MAX(gpa) FROM student_grades WHERE gpa IS NOT NULL;

b. SELECT (gpa) FROM student_grades GROUP BY semester_end WHERE gpa IS NOT NULL;

c. SELECT MAX(gpa) FROM student_grades WHERE gpa IS NOT NULL GROUP BY semester_end;

d. SELECT MAX(gpa) GROUP BY semester_end WHERE gpa IS NOT NULL FROM student_grades;

e. SELECT MAX(gpa) FROM student_grades GROUP BY semester_end WHERE gpa IS NOT NULL;

7. Which of the following tasks can be performed by using the TO_CHAR function?

a. Convert '10'to 10

b. Convert 10 to '10'

c. Convert 'TEN' to 10

d. Convert a date to a character expression

e. Convert a character expression to a date

8. Which of the following SELECT statements will get the result 'elloworld' from the string 'HelloWorld'?

a. SELECT SUBSTR ('HelloWorld',1) FROM dual;

b. SELECT INITCAP(TRIM('HellowWorld', 1,1) FROM dual;

c. SELECT LOWER (SUBSTR ('HellowWorld', 2,1) FROM dual;

d. SELECT LOWER (SUBSTR('HellowWorld', 2,1) FROM dual;

e. SELECT LOWER (TRIM ('H' FROM 'Hello World')) FROM dual;

9. Where is the GROUP BY clause statement placed in a SELECT statement that includes a WHERE clause?

a. Immediately after the SELECT clause

b. Before the WHERE clause

c. After the ORDER BY clause

d. After the WHERE clause

10. Which operators can be used in an outer join condition?

a. =

b. OR

c. IN

d. AND

11. Which type of view is implemented as a subquery embedded in the FROM clause of a SELECT statement and is identified by an alias?

a. Simple

b. Inline

c. Complex

d. Nested

12. Evaluate the following SQL statement:

SELECT ROUND (TRUNC (MOD (1600, 10),-1), 2) FROM dual;

What will be displayed?

a. 0

b. 1

c. 0.00

d. An error statement

SQL QueriesQuestions1. The following relations keep track of airline flight information:

Flights(flno: integer, from: string, to: string, distance: integer, departs:time,arrives: time, price: integer)Aircraft(aid: integer, aname: string, cruisingrange: integer)Certified(eid: integer, aid: integer)Employees(eid: integer, ename: string, salary: integer)

Note that the Employees relation describes pilots and other kinds of employeesaswell; every pilot is certified for some aircraft, and only pilots are certified tofly.Write each of the following queries in SQL.

a. Find the names of aircraft such that all pilots certified to operate them earnmore than $80,000.b. For each pilot who is certified for more than three aircraft, find the eid and themaximum cruisingrange of the aircraft for which she or he is certified.c. Find the names of pilots whose salary is less than the price of the cheapestroute from Los Angeles to Honolulu.d. For all aircraft with cruisingrange over 1000 miles, find the name of theaircraft and the average salary of all pilots certified for this aircraft.e. Find the names of pilots certified for some Boeing aircraft.f. Find the aids of all aircraft that can be used on routes from Los Angeles toChicago.g. Identify the routes that can be piloted by every pilot who makes more than$100,000.h. Print the enames of pilots who can operate planes with cruisingrange greaterthan 3000 miles but are not certified on any Boeing aircraft.i. A customer wants to travel from Madison to New York with no more than twochanges of flight. List the choice of departure times from Madison if thecustomer wants to arrive in New York by 6 p.m.j. Compute the difference between the average salary of a pilot and the averagesalary of all employees (including pilots).k. Print the name and salary of every nonpilot whose salary is more than theaverage salary for pilots.l. Print the names of employees who are certified only on aircrafts with cruisingrange longer than 1000 miles.m. Print the names of employees who are certified only on aircrafts with cruisingrange longer than 1000 miles, but on at least two such aircrafts.n. Print the names of employees who are certified only on aircrafts with cruisingrange longer than 1000 miles and who are certified on some Boeing aircraft.a)select a.aname,e.ename,e.salary fromaircraft a,employees e,certified cwhere e.eid=c.eidand c.aid=a.aidand e.salary >$80,000.b)select c.eid,max(a.cruisingrange) from certified c,aircraft awhere c.aid=a.aid group by c.eid having count(*)>3;c)select e.ename from employees e where e.salary 1000group by a.aname;e)select e.ename from employees e ,certified c,aircraft awhere e.eid=c.eidand c.aid=a.aid and a.aname=' Boeing aircraft';f)select a.aid from aircraft a where a.aid in(f.flno from flights f where f.from=' Los Angeles'and f.to='chicago');

2. Consider the following relational schema. An employee can work in more thanone department; the pct_time filed of the Works relation shows the percentage oftime that a given employee works in a given department.

Emp(eid: integer, ename: string, age: integer, salary: real)Works(eid: integer, did: integer, pct_time: integer)Dept(did: integer, dname: string, budget: real, managerid: integer)

Write the following queries in SQL:

a. Print the names and ages of each employee who works in both the Hardwaredepartment and the Software department.b. For each department with more than 20 full-time-equivalent employees (i.e.,where the part-time and full-time employees add up to at least that many fulltimeemployees), print the did together with the number of employees thatwork in that department.c. Print the name of each employee whose salary exceeds the budget of all of thedepartments that he or she works in.d. Find the managerids of managers who manage only departments with budgetsgreater than $1 million.e. Find the enames of managers who manage the departments with the largestbudgets.f. If a manager manages more than one department, he or she controls the sumof all the budgets for those departments. Find the managerids of managerswho control more than $5 million.g. Find the managerids of managers who control the largest amounts.h. Find the enames of managers who manage only departments with budgetslarger than $1 million, but at least one department with budget less than $5million.a)Select e.ename,e.age from emp e,works w,dept dwhere e.eid=w.eid and w.did=d.did and d.dname='Hardware'and d.dname='software';c)select e.ename from emp ewhere e.sal > all(select d.budget from dept d,works wwhere e.eid=w.eid and w.did=d.did);d)select d.managerid,d.dname fromdept d where d.budget>10,00,000;e)select e.ename from emp ewhere e.eid in(select d.managerid from dept d where d.budget=(select max(d1.budget) from dept1));f)select managerid ,sum(budget)from deptgroup by manageridhaving sum(budget)>500000;h)select e.ename from emp e,dept dwhere e.eid=d.manageridgroup by e.eidhaving (d.budget>1,00,000 )and (d.budget