Publish 3rd highest Salary:
mysql> select * from employee;
+------+---------+------+--------+
| eid | name | did | salary |
+------+---------+------+--------+
| 1 | gaurav | 1 | 1000 |
| 2 | gagan | 5 | 6000 |
| 3 | deepa | NULL | 5000 |
| 4 | neha | NULL | 2000 |
| 5 | saurabh | NULL | 4000 |
| 6 | meenu | NULL | 3000 |
+------+---------+------+--------+
6 rows in set (0.00 sec)
mysql> select * from employee order by salary desc;
+------+---------+------+--------+
| eid | name | did | salary |
+------+---------+------+--------+
| 2 | gagan | 5 | 6000 |
| 3 | deepa | NULL | 5000 |
| 5 | saurabh | NULL | 4000 |
| 6 | meenu | NULL | 3000 |
| 4 | neha | NULL | 2000 |
| 1 | gaurav | 1 | 1000 |
+------+---------+------+--------+
6 rows in set (0.00 sec)
mysql> select * from employee order by salary desc limit 2,1;
+------+---------+------+--------+
| eid | name | did | salary |
+------+---------+------+--------+
| 5 | saurabh | NULL | 4000 |
+------+---------+------+--------+
1 row in set (0.00 sec)
mysql> select * from employee;
+------+---------+------+--------+
| eid | name | did | salary |
+------+---------+------+--------+
| 1 | gaurav | 1 | 1000 |
| 2 | gagan | 5 | 6000 |
| 3 | deepa | NULL | 5000 |
| 4 | neha | NULL | 2000 |
| 5 | saurabh | NULL | 4000 |
| 6 | meenu | NULL | 3000 |
+------+---------+------+--------+
6 rows in set (0.00 sec)
mysql> select * from employee order by salary desc;
+------+---------+------+--------+
| eid | name | did | salary |
+------+---------+------+--------+
| 2 | gagan | 5 | 6000 |
| 3 | deepa | NULL | 5000 |
| 5 | saurabh | NULL | 4000 |
| 6 | meenu | NULL | 3000 |
| 4 | neha | NULL | 2000 |
| 1 | gaurav | 1 | 1000 |
+------+---------+------+--------+
6 rows in set (0.00 sec)
mysql> select * from employee order by salary desc limit 2,1;
+------+---------+------+--------+
| eid | name | did | salary |
+------+---------+------+--------+
| 5 | saurabh | NULL | 4000 |
+------+---------+------+--------+
1 row in set (0.00 sec)
No comments:
Post a Comment