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.


Ramesh k
Posts: 1
 Ramesh k
Topic starter
(@Ramesh k)
Joined: 2 months 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
jeevan 123
Posts: 18
(@jeevan303500)
Active Member
Joined: 1 year ago

For last record

SELECT * FROM EmployeeInfo

WHERE EmpID=(SELECT MAX(EmpID)

FROM Employeelnfo);
Reply


jeevan 123
Posts: 18
(@jeevan303500)
Active Member
Joined: 1 year ago

 

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


Leave a reply

Author Name

Author Email

Title *

 
Preview 0 Revisions Saved
Share: