1675135297322
1675135297322
1675135297322
Biplab Parida
4. SQL Query to display full name?
Biplab Parida
7.Write a query to fetch details of all
employees excluding few Employees :
MYSQL:
A.SELECT CURDATE ( );
OR
SELECT CURRENT_DATE();
ORACLE:
SELECT
TO_CHAR(LAST_DAY(ADD_MONTHS(SYSDATE-
1)),’DAY’) FROM DUAL;
MYSQL:
A.SELECT DAYNAME
(LAST_DAY(DATE_ADD(CURDATE ()-1,
INTERVAL -1 MONTH)))
Biplab Parida
10. Write an SQL query to fetch the
employee FIRST names and replace
the A with ‘@’?
ORACLE:
A.SELECT SUBSTR (EMAILID,
INSTR(EMAILID,’@’) +1 FROM EMPLOYEE;
MYSQL:
A.SELECT SUBSTRING (EMAILID,
INSTR(EMAILID,"@")+1) FROM EMPLOYEE;
Biplab Parida
13. Write an SQL query to create a new
table with data and structure copied
from another table:
ORACLE:
SELECT * FROM EMPLOYEE WHERE
DATEOFJOINING BETWEEN ‘1-JAN-2020’
AND ’31-DEC-2020’;
OR
SELECT * FROM EMPLOYEE WHERE
TO_CHAR(DATEOFJOINING,’YYYY’)=2020;
MYSQL:
SELECT * FROM EMPLOYEE WHERE YEAR
(DATEOFJOINING)=2020;
First Employee:
SELECT * FROM EMPLOYEE WHERE EMPID =
(SELECT MIN(EMPID) FROM EMPLOYEE);
Last Employee:
SELECT * FROM EMPLOYEE WHERE EMPID =
(SELECT MAX(EMPID) FROM EMPLOYEE);
Biplab Parida
19. List the ways to get the count of
records in a table:
SELECT COUNT (*) FROM EMPLOYEE;
SELECT COUNT (EMPID) FROM
EMPLOYEE;
SELECT COUNT (1) FROM EMPLOYEE;
ORACLE:
SELECT * FROM EMPLOYEE WHERE
ROWNUM <= (SELECT COUNT(*) FROM
EMPLOYEE) / 2;
MYSQL:
SELECT * FROM Customers LIMIT
(select COUNT(*)/2 from Customers);
ORACLE:
SELECT E.EMPID, E.FIRSTNAME || ‘ ’ ||
E.LASTNAME, NVL (C.BRAND, ‘NOT
ASSIGNED’) FROM EMPLOYEE E LEFT JOIN
COMPUTER C ON E.COMPID = C.COMPID;
MYSQL :
IFNULL () FUNCTION CAN BE USED
INSTEAD OF NVL
Biplab Parida
30. Find Nth Highest salary :
OR
OR
Link in Comment
Biplab Parida