Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Single-Row (Single Value) Subqueries

1. Return first name, last name, and salary for employees who earn the lowest salary.

FIRST_NAME LAST_NAME SALARY

Trish Albert $1,800.00

2. Return customer id, customer name, and available credit (credit limit – balance) for
customers where their available credit is greater than the average available credit for all
customers. Sort available credit descending. Return first six rows only.

CUSTOMER_ID CUSTOMER AVAILABLE_CREDIT

290 Jerry's Sports $43,624.15


190 Digital Junkies $34,399.15
260 Worldwide Digital Inc $34,399.15
110 Worldwide Digital Inc $32,439.15
120 Best Digital Products $29,639.45
280 Frys Electronics $26,999.25

3. Return customer name, order id, and the number of days to ship the orders. Only return
orders that took longer than the average number of days to ship all orders. Sort by the
number of days to ship descending.

CUSTOMER_NAME ORDER_ID DAYS_TO_SHIP

Worldwide Digital Inc 1002 15


Best Digital Products 1001 10
Everything Electronics 1000 9
Best Digital Products 1005 8

4. Return employee information shown for employees that have a monthly salary > the
average monthly salary for department code MA. Sort monthly salary descending. Return
the first eight rows only.

FIRST_NAME LAST_NAME DEPARTMENT_NAME JOB_TITLE SALARY

Terry Manis Administration Department Manager $11,000.00


Sandy Black Accounting Department Manager $7,700.00
Janis Hill Video Games Sales Associate $6,585.00
Lisa James Major Appliances Department Manager $6,500.00
Jim Smith Electronics Sales Associate $6,000.00
Dave Bernard Electronics Department Manager $6,000.00
Steve Carr Video Games Department Manager $5,500.00
Jane White Major Appliances Sales Associate $4,500.00
5. What are the job codes, job titles and employee names for employees whose job code are
not the same as Sharron Evans? Use last name 'Evans' in subquery. Sort employee name
within job title.

JOB_CODE JOB_TITLE EMPLOYEE_NAME

DT_MGR Department Manager Dave Bernard


DT_MGR Department Manager Lauren Alexander
DT_MGR Department Manager Lisa James
DT_MGR Department Manager Sandy Black
DT_MGR Department Manager Steve Carr
DT_MGR Department Manager Terry Manis
IT_DEV Software Developer Bob Allan
IT_DEV Software Developer Greg Zimmerman
IT_DEV Software Developer Paula Morris
IT_DEV Software Developer Rick Peters
AD_TRN Trainer Scott Long

6. Which employees have the same department code as the Video Games department? Use
"Video Games" in the subquery. Sort by last name.

EMPLOYEE_NAME

Trish Albert
Steve Carr
Janis Hill
Jake Lee

7. Return employee name, job code, and job title for employees that have the same job code
as an employe id entered as a Bind variable. Sort by last name.

Bind variable Value

:ENTER_EMPLOYEE_ID 139 (Try other employee ids)

EMPLOYEE_NAME JOB_CODE JOB_TITLE

Bob Allan IT_DEV Software Developer


Paula Morris IT_DEV Software Developer
Rick Peters IT_DEV Software Developer
Greg Zimmerman IT_DEV Software Developer
8. Return all employees who have a monthly salary greater than the monthly salary of Bob
Allan and are in the same department as Janice Harper. Use the last names 'Allan' and
'Harper' in the subqueries. Sort monthly salary in descending sequence.

EMPLOYEE DEPARTMENT_NAME MONTHLY_SALARY

Jim Smith Home Theatre $6,000.85


Dave Bernard Home Theatre $6,000.00
Janice Harper Home Theatre $2,900.00

You might also like