Which of the following queries will result in an error message? Why? (Uses tables created in the Chapter 4 Lab Activity.)

1. SELECT UPPER(FirstName || ‘ ‘ || LastName) FROM student;
2. SELECT DeptId, COUNT (*) FROM employee;
3. INSERT INTO DEPT VALUES (90, RESEARCH, NULL, NULL);
4. SELECT DeptId, SUM (Salary)
FROM employee
WHERE SUM (Salary) > 200000
GROUP BY DeptId;
5. SELECT SUM(EmployeeId)
FROM employee;


1.
SQL> SELECT UPPER(FirstName || ' ' || LastName) FROM student;
SELECT UPPER(FirstName || ' ' || LastName) FROM student
*
ERROR at line 1:
ORA-00904: "LASTNAME": invalid identifier
(Invalid column names)
2.
SQL> SELECT DeptId, COUNT (*) FROM employee;
SELECT DeptId, COUNT (*) FROM employee
*
ERROR at line 1:
ORA-00937: not a single-group group function
(Missing GROUP BY DeptId)
3.
SQL> INSERT INTO DEPT VALUES (90, RESEARCH, NULL, NULL);
INSERT INTO DEPT VALUES (90, RESEARCH, NULL, NULL)
*
ERROR at line 1:
ORA-00984: column not allowed here
(RESEARCH should be enclosed within single quotes)
4.
SQL> SELECT DeptId, SUM (Salary)
2 FROM employee
3 WHERE SUM (Salary) > 200000
4 GROUP BY DeptId;
WHERE SUM (Salary) > 200000
*
ERROR at line 3:
ORA-00934: group function is not allowed here
(WHERE should be replaced by HAVING clause)
5.
SQL> SELECT SUM(EmployeeId)
2 FROM employee;
SUM(EMPLOYEEID)
---------------
2013
(No error, but sum of EmployeeId does not make sense)

Computer Science & Information Technology

You might also like to view...

The systems development life cycle provides a structure for managing complex information technology projects

Indicate whether the statement is true or false

Computer Science & Information Technology

IPsec operates at which of the following layers of the OSI model?

A. Session B. Application C. Presentation D. Network

Computer Science & Information Technology

PHP support Perl Compatible Regular Expressions (PCRE).

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Sharing sensitive information between applications has made writing code more of an orchestrated event than a ____ practice.

A. Group B. Solitary C. Team D. Lonely

Computer Science & Information Technology