using rename in combination with join -


Using RENAME in combination with JOIN - SQL

Example gives pairs of ids of students having the same name, by joining two renamings of IS_CALLED. Example gives an equivalent expression in SQL.

Example: Renaming and joining

Student Sid1 is called Name and so is student Sid2

SELECT *

FROM   (SELECT StudentId AS Sid1, Name FROM IS_CALLED)

     NATURAL JOIN

     (SELECT StudentId AS Sid2, Name FROM IS_CALLED)

As before, the result sagely tells us that student S1 (Anne) has the same name as herself and also shows two pairings of S1 with S5 (both named Boris). The pairing of a student id with itself can be avoided by adding WHERE Sid1 < > Sid2 to the WHERE clause. The duplicate pairings can further be avoided by using < instead of < > in this addition, but that trick assumes that an ordering is defined for type SID, which is not necessarily the case.

Request for Solution File

Ask an Expert for Answer!!
PL-SQL Programming: using rename in combination with join -
Reference No:- TGS0180842

Expected delivery within 24 Hours