HomePagev2 Forums SQL Discussions What are self joins and why are they useful? Reply To: What are self joins and why are they useful?

  • Sai Gowtham Babu AMBURI Gowtham Babu AMBURI

    Member
    September 10, 2020 at 8:37 pm

    a self join can be used to join a table by itself and perform some conditions and  calculations on it

    For example, we can sort the data using the below example based on salary of a person.

    `SELECT a.ID, b.NAME, a.SALARY
    FROM CUSTOMERS a, CUSTOMERS b
    WHERE a.SALARY < b.SALARY;`
    

     

    I would @satishvadlamani sir, @rajasekhar123, @sindhri, @shreekadiyala, @saichaitanya, @akondiseetharam to add more points for my explanation🙂