0% found this document useful (0 votes)
7 views3 pages

Query

Uploaded by

John Banik
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Query

Uploaded by

John Banik
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CREATE TABLE Worker (

WORKER_ID INT NOT NULL PRIMARY KEY,

FIRST_NAME CHAR(25),

LAST_NAME CHAR(25),

SALARY INT,

JOINING_DATE DATETIME,

DEPARTMENT CHAR(25)

);

INSERT INTO Worker (WORKER_ID, FIRST_NAME, LAST_NAME, SALARY, JOINING_DATE, DEPARTMENT) VALUES

(1, 'Monika', 'Arora', 100000, '2021-02-20 09:00:00', 'HR'),

(2, 'Niharika', 'Verma', 80000, '2021-06-11 09:00:00', 'Admin'),

(3, 'Vishal', 'Singhal', 300000, '2021-02-20 09:00:00', 'HR'),

(4, 'Amitabh', 'Singh', 500000, '2021-02-20 09:00:00', 'Admin'),

(5, 'Vivek', 'Bhati', 500000, '2021-06-11 09:00:00', 'Admin'),

(6, 'Vipul', 'Diwan', 200000, '2021-06-11 09:00:00', 'Account'),

(7, 'Satish', 'Kumar', 75000, '2021-01-20 09:00:00', 'Account'),

(8, 'Geetika', 'Chauhan', 90000, '2021-04-11 09:00:00', 'Admin');

CREATE TABLE Bonus (

WORKER_REF_ID INT,

BONUS_AMOUNT INT,

BONUS_DATE DATETIME,

FOREIGN KEY (WORKER_REF_ID) REFERENCES Worker(WORKER_ID) ON DELETE CASCADE

);

INSERT INTO Bonus (WORKER_REF_ID, BONUS_AMOUNT, BONUS_DATE) VALUES

(1, 5000, '2023-02-20'),

(2, 3000, '2023-06-11'),

(3, 4000, '2023-02-20'),

(1, 4500, '2023-02-20'),

(2, 3500, '2023-06-11');

CREATE TABLE Title (


WORKER_REF_ID INT,

WORKER_TITLE CHAR(25),

AFFECTED_FROM DATETIME,

FOREIGN KEY (WORKER_REF_ID) REFERENCES Worker(WORKER_ID) ON DELETE CASCADE

);

INSERT INTO Title (WORKER_REF_ID, WORKER_TITLE, AFFECTED_FROM) VALUES

(1, 'Manager', '2023-02-20 00:00:00'),

(2, 'Executive', '2023-06-11 00:00:00'),

(8, 'Executive', '2023-06-11 00:00:00'),

(5, 'Manager', '2023-06-11 00:00:00'),

(4, 'Asst. Manager', '2023-06-11 00:00:00'),

(7, 'Executive', '2023-06-11 00:00:00'),

(6, 'Lead', '2023-06-11 00:00:00'),

(3, 'Lead', '2023-06-11 00:00:00');

SQL Query
1) Write SQL Query to Display FIRST_NAME with Alias WORKER_NAME.
2) Write SQL Query to Display FIRST_NAME in Upper Case from the Worker Table.
3) Write SQL Query to Display Unique DEPARTMENT Values from the Worker Table.
4) Write SQL Query to Display the First 3 Chars of FIRST_NAME from the Worker Table.
5) Write SQL Query to Find the Position of Alphabet ‘a’ in the FIRST_NAME Column.
6) Write SQL Query to Fetch FIRST_NAME from the Worker Table With No White Spaces on the
Right.
7) Write SQL Query to List DEPARTMENT from the Worker Table With No White Spaces on the
Left.
8) Write SQL Query to Display Unique DEPARTMENT Values and Their Lengths from the Worker
Table.
9) Write SQL Query to Replace ‘a’ with ‘A’ in FIRST_NAME from the Worker Table.
10) Write SQL Query to Combine FIRST_NAME and LAST_NAME into COMPLETE_NAME.
11) Write SQL Query to Print Worker Details Ordered by FIRST_NAME Ascending and
DEPARTMENT Descending.
12) Write SQL Query to Print Worker Details with First Names “Vipul” and “Satish”.
13) Write SQL Query to Print Worker Details Excluding First Names (“Vipul” and “Satish”).
14) Write SQL Query to Print Worker Details with DEPARTMENT Name as “Admin”.
15) Write SQL Query to Print Worker Details Whose FIRST_NAME Contains ‘a’.
16) Write SQL Query to List Worker Info Whose FIRST_NAME Ends with ‘a’.
17) Write SQL Query to List Worker Count Per Department in Descending Order.
18) Write SQL Query to Print Worker Details Who Are Also Managers.
19) Write SQL Query to Show Only Odd Rows from a Table.
20) Write SQL Query to Clone a New Table from Another Table.
21) Write SQL Query to Fetch the List of Employees with the Same Salary.
22) Write SQL Query to List the Employee with the Second-Highest Salary.
23) Write SQL Query to Show All Departments with the Number of People in There.
24) Write SQL Query to Fetch Departments and Their Total Salaries.

You might also like