Find five random employees from a random department

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Find five random employees from a random department

The image displays a table with three columns titled DEPTNO, DNAME, and LOC. Below is a transcription of the data presented in the table:

1. **DEPTNO: 10**
   - **DNAME: ACCOUNTING**
   - **LOC: NEW YORK**

2. **DEPTNO: 20**
   - **DNAME: RESEARCH**
   - **LOC: DALLAS**

3. **DEPTNO: 30**
   - **DNAME: SALES**
   - **LOC: CHICAGO**

4. **DEPTNO: 40**
   - **DNAME: OPERATIONS**
   - **LOC: BOSTON**

This table lists various departments identified by their department numbers, names, and locations.
Transcribed Image Text:The image displays a table with three columns titled DEPTNO, DNAME, and LOC. Below is a transcription of the data presented in the table: 1. **DEPTNO: 10** - **DNAME: ACCOUNTING** - **LOC: NEW YORK** 2. **DEPTNO: 20** - **DNAME: RESEARCH** - **LOC: DALLAS** 3. **DEPTNO: 30** - **DNAME: SALES** - **LOC: CHICAGO** 4. **DEPTNO: 40** - **DNAME: OPERATIONS** - **LOC: BOSTON** This table lists various departments identified by their department numbers, names, and locations.
The image shows a table with the following columns and data:

- **EMPNO (Employee Number):** 
  - 7839
  - 7566

- **ENAME (Employee Name):** 
  - KING
  - JONES

- **JOB (Job Title):** 
  - PRESIDENT
  - MANAGER

- **MGR (Manager Number):** 
  - (null) for KING
  - 7839 for JONES

- **HIREDATE (Hire Date):** 
  - 17-NOV-81 for KING
  - 02-APR-81 for JONES

- **SAL (Salary):**
  - 5000 for KING
  - 2975 for JONES

- **COMM (Commission):**
  - (null) for both KING and JONES

- **DEPTNO (Department Number):** 
  - 10 for KING
  - 20 for JONES

**Explanation:**

This table represents employee data, where each row corresponds to an individual employee's details. The columns include identifiers like employee number and name, job information, manager references, hire date, and financial details such as salary and commission. Null values indicate missing data in the manager and commission columns for some entries.
Transcribed Image Text:The image shows a table with the following columns and data: - **EMPNO (Employee Number):** - 7839 - 7566 - **ENAME (Employee Name):** - KING - JONES - **JOB (Job Title):** - PRESIDENT - MANAGER - **MGR (Manager Number):** - (null) for KING - 7839 for JONES - **HIREDATE (Hire Date):** - 17-NOV-81 for KING - 02-APR-81 for JONES - **SAL (Salary):** - 5000 for KING - 2975 for JONES - **COMM (Commission):** - (null) for both KING and JONES - **DEPTNO (Department Number):** - 10 for KING - 20 for JONES **Explanation:** This table represents employee data, where each row corresponds to an individual employee's details. The columns include identifiers like employee number and name, job information, manager references, hire date, and financial details such as salary and commission. Null values indicate missing data in the manager and commission columns for some entries.
Expert Solution
Step 1

 

  • Syntax to select a random record:

           SELECT column FROM  (SELECT column FROM table  ORDER BY dbms_random.value)  WHERE rownum =1  

By using the above syntax, Initially, a random department (DEPTNO) is retrieved from the DEPT table. Using DEPTNO, 5 random employee records are retrieved from the EMP table. 

NOTE: Sample Data is considered to implement query on EMP and DEPT table.

Step 2

Data in EMP Table:

Computer Science homework question answer, step 2, image 1

Data in DEPT table:

Computer Science homework question answer, step 2, image 2

steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Knowledge Booster
Complex Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education