May 17, 2022 4:16 pm
Write a query to display the first and the last record from the Employee info table.
For First Record
SELECT * FROM EmployeeInfo WHERE EmpID=(SELECT MIN(EmpID) FROM Employeelnfo);
3 Replies
May 17, 2022 4:25 pm
For last record
SELECT * FROM EmployeeInfo WHERE EmpID=(SELECT MAX(EmpID) FROM Employeelnfo);
May 17, 2022 4:37 pm
select *from emp order by EmployeeId ASC LIMIT 1) UNION (select *from emp order by EmployeeId DESC LIMIT 1);
May 17, 2022 4:40 pm
+------------+--------------+----------------+ | EmployeeId | EmployeeName | EmployeeSalary | +------------+--------------+----------------+ | 1 | JohnS | 457647 | | 4 | Peter | 989322 | +------------+--------------+----------------+ 2 rows in set (0.00 sec)