Using rename in combination with join - sql, PL-SQL Programming

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.

Posted Date: 1/18/2013 5:08:05 AM | Location : United States







Related Discussions:- Using rename in combination with join - sql, Assignment Help, Ask Question on Using rename in combination with join - sql, Get Answer, Expert's Help, Using rename in combination with join - sql Discussions

Write discussion on Using rename in combination with join - sql
Your posts are moderated
Related Questions
Example of UNWRAP Operator - SQL Example here shows how unwrapping can be done in longhand in SQL. Example: Unwrapping in SQL Letting CONTACT_INFO_WRAPPED denote the res

Closest Approximation to Relational Union - SQL Actually, just as SQL has several varieties of JOIN, it also has several varieties of UNION, none of which is equivalent to th

Special cases of projection This section describes the identity projection, r {ALL BUT}, and the projection on no attributes, r { }, which yields TABLE_DUM when r is empty, ot

Row Operators The Row operators return or reference the particular rows. ALL retains the duplicate rows in the result of a query or in an aggregate expression. The DISTINCT el

Creating and Destroying Base Tables: Example shows an SQL command to create the base table counterpart of the ENROLMENT variable Example  Creating a base table. CREATE T

Initializing Records The illustration below shows that you can initialize a record in its type definition. Whenever you declare a record of the type TimeRec, its 3 fields supp

Using a join on 2 tables, select all columns and 10 rows from the 2 tables without the use of a Cartesian product. Query: SELECT * FROM EMPLOYEE1 E JOIN STAFF S ON E.EMP_

Closing a Cursor Variable The CLOSE statement disables the cursor variable. After that, the related result set is undefined. The syntax for the same is as shown below: CLOS

Write SQL queries to solve the following specifications. Include the query AND THE OUTPUT.  A screen dump of the output is acceptable. Show as many rows as you can. A screen dump i

Transaction context As the figure shows, the major transaction shares its context with the nested transactions, but not with the autonomous transactions. Similarly, If one aut