Write an sql query to show the top n records of a table


Assignment

If we were to create the following database, there are specific commands that are needed to generate a SQL Query. Review the information and answer the questions.
CREATE DATABASE ORG;
SHOW DATABASES;
USE ORG;

CREATE TABLE Worker (
WORKER_ID INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
FIRST_NAME CHAR(25),
LAST_NAME CHAR(25),
SALARY INT(15),
JOINING_DATE DATETIME,
DEPARTMENT CHAR(25)
);

INSERT INTO Worker

(WORKER_ID, FIRST_NAME, LAST_NAME, SALARY, JOINING_DATE, DEPARTMENT) VALUES
(001, 'Monika', 'Stevens', 100000, '14-02-20 09.00.00', 'HR'),
(002, 'Nic', 'Verma', 80000, '14-06-11 09.00.00', 'Admin'),
(003, 'Steven', 'Farcie', 300000, '14-02-20 09.00.00', 'Accounting'),
(004, 'Marisa', 'Singh', 500000, '11-02-20 09.00.00', 'Executive'),
(005, 'Vivek', 'Bart', 500000, '14-06-12 09.00.00', 'Admin'),
(006, 'JR', 'Diwan', 200000, '14-06-11 09.00.00', 'Executive'),
(007, 'MJ', 'Crocket', 75000, '14-01-20 09.00.00', 'Account'),
(008, 'Thomas', 'Ebert', 90000, '14-04-11 09.00.00', 'Admin');
(009, ‘George', ‘Smith', 73500, '12-05-22 09.00.00', ‘IT');
(010, ‘Tom', ‘George', 125000, '13-06-19 09.00.00', ‘IT');
(011, ‘Jerry', ‘Crooke', 65400, '14-07-18 09.00.00', ‘Training');
(012, ‘Miguel', ‘Sanchez', 185000, '15-08-17 09.00.00', ‘Facility');

Task

o Write an SQL query to show the top n (say 8) records of a table. To complete the answer, execute the query and insert a full-screen snapshot with the query.

o Write an SQL query to fetch the last seven records from a table. To complete the answer, execute the query and insert a full-screen snapshot with the query.

o Write an SQL query to fetch nth max salaries from a table. To complete the answer, execute the query and insert a full-screen snapshot with the query.

Format your assignment according to the following formatting requirements:

o The answer should be typed, using Times New Roman font (size 12), double spaced, with one-inch margins on all sides.

o The response also includes a cover page containing the title of the assignment, the student's name, the course title, and the date. The cover page is not included in the required page length.

o Also include a reference page. The Citations and references must follow APA format. The reference page is not included in the required page length.

Solution Preview :

Prepared by a verified Expert
PL-SQL Programming: Write an sql query to show the top n records of a table
Reference No:- TGS03180891

Now Priced at $50 (50% Discount)

Recommended (99%)

Rated (4.3/5)