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
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

Example of Null operator - NiNo Rule If we wanted to make HIGHER_OF adhere to "NULL in, NULL out"-let's call it the NiNo rule-we would have to write something like what is sho

set serveroutput on declare a number(5); b number(5); c number(5); begin a:=&a; b:=&b; c:=a/b; dbms_output.put_line(c); exception when zero_divide then d

Using the student and faculty tables create a select query that outputs all students for a specific advisor. Generate the execution plan, select out the explain plan . Create an

Quantification in SQL To quantify something, as the theory book has it, is to state its quantity, to say how many of it there are. For example, in Tutorial D the expression CO

At times, customers make mistakes in submitting their orders and call to cancel the order. Brewbean’s wants to create a trigger that automatically updates the stock level of all pr

How Bulk Binds Improve Performance The assigning of values to the PL/SQL variables in SQL statements is known as binding. The binding of the whole collection at once is know

Controlling Cursor Variables You use 3 statements to control the cursor variable: OPEN-FOR, FETCH, & CLOSE. At First, you OPEN a cursor variable FOR a multi-row query. Then, y

Implicit Cursors The Oracle implicitly opens a cursor to process each SQL statement not related with an explicitly declared cursor. The PL/SQL lets you refer to the most recen

Data Abstraction The Data abstraction extracts the important properties of data while ignoring the not necessary details. Once you design a data structure, you can fail to reme