SQL ASSIGNMENTS

#snehal #sheth

snehal sheth Jul 07 2021 · 1 min read
Share this

ASSIGNMENT-6

Q-1. Write an SQL query to print details of the Workers who have joined in Feb’2014.

SELECT * FROM WORKERS WHERE YEAR(JOINING_DATE)= 2014 AND MONTH(JOINING_DATE)=2

Q-2. Write an SQL query to fetch duplicate records having matching data in some fields of a table.

SELECT WORKER_TITLE, AFFECTED_FROM, COUNT(*)

FROM Title

GROUP BY WORKER_TITLE, AFFECTED_FROM

HAVING COUNT(*) > 1;

Q-3. How to remove duplicate rows from Employees table

select *, COUNT(*) AS COUNTS FROM WORKERS GROUP BY WORKER_ID,FIRST_NAME,LAST_NAME,SALARY,JOINING_DATE,DEPARTMENT,EMAIL,GMAIL

HAVING COUNT(*) >=1

ASSIGNMENT-7

Q-1. Write an SQL query to show only odd rows from a table.

Select * from TITLE where (WORKER_REF_ID % 2) = 1

Q-2. Write an SQL query to clone a new table from another table.

SELECT * INTO WORKERSCLONE FROM WORKERS;

ASSIGNMENT-8

Q-1. Write an SQL query to fetch intersecting records of two tables.

SELECT * FROM WORKERS

INTERSECT

SELECT * FROM WORKERSCLONE;

Q-2. Write an SQL query to show records from one table that another table does not have.

SELECT WORKER_ID

FROM WORKERS

WHERE WORKER_ID NOT IN

(SELECT DISTINCT WORKER_REF_ID

FROM TITLE)

Comments
Read next