Forum

Write a query to di...
 
Share:
Notifications
Clear all

Write a query to display the first and the last record from the Employee info table.


Posts: 1
Guest
Topic starter
(@Ramesh k)
New Member
Joined: 2 years ago

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
Posts: 18
(@jeevan303500)
Active Member
Joined: 3 years ago

For last record

SELECT * FROM EmployeeInfo

WHERE EmpID=(SELECT MAX(EmpID)

FROM Employeelnfo);
Reply

Self Learning Video Tutorials - Software Course

Posts: 18
(@jeevan303500)
Active Member
Joined: 3 years ago

 

select *from emp order by EmployeeId ASC LIMIT 1)
UNION
(select *from emp order by EmployeeId DESC LIMIT 1);
Reply
Posts: 18
(@jeevan303500)
Active Member
Joined: 3 years ago
+------------+--------------+----------------+
| EmployeeId | EmployeeName | EmployeeSalary |
+------------+--------------+----------------+
| 1          | JohnS     | 457647         |
| 4          | Peter       | 989322         |
+------------+--------------+----------------+
2 rows in set (0.00 sec)
Reply

Self Learning Video Tutorials - Software Course

Leave a reply

Author Name

Author Email

Title *

 
Preview 0 Revisions Saved
Share: