Interview Questions.

Top 10 Complex Sql Queries Interview Questions

fluid

Top 10 Complex Sql Queries Interview Questions

Q1. What Is The Query To Fetch Last Record From The Student Table?

SELECT * FROM Student order by way of identity desc limit 1

Q2. What Is The Query To Fetch First Record From Student Table?

SELECT * from Student in which identification = 1;

Q3. What Is Query To Display Nth Record From Student Table?

Select * from Student  where identification = $n;

Q4. Query To Find Duplicate Rows In Table?

SELECT std_id, COUNT(std_id) as cnt FROM Student GROUP by std_id having cnt > 1

Q5. How To Display Odd Rows In Student Table?

SELECT * FROM Student where MOD(id,2) = 1

Q6. How Can I Create Table With Same Structure Of Student Table?

Create table std as Select * from Student;

Q7. Query To Find Second Highest Marks Of A Student?

Based On the Below Student desk We are Written All the Queries.

Student Table

SELECT marks FROM Student ORDER by marks DESC limit 1, 1;

Q8. How To Display Even Rows In Student Table?

SELECT * FROM Student wherein MOD(identification,2) = zero

Q9. What Is Query To Display Last three Records From Student Table?

SELECT *  FROM Student order by means of std_id Desc restrict 3

Q10. How To Get 3 Highest Marks From Student Table?

SELECT awesome(marks) FROM Student ORDER BY marks DESC LIMIT 0,3




CFG